diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 00000000..16636ff1 --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,51 @@ +name: CMake + +on: [push] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + build: + # The CMake configure and build commands are platform agnostic and should work equally + # well on Windows or Mac. You can convert this to a matrix build if you need + # cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: ubuntu-18.04 + + steps: + - uses: actions/checkout@v2 + - name: Install dependeces + working-directory: ${{github.workspace}} + shell: bash + run: | + sudo apt-get install libudev-dev + sudo apt-get install libboost-all-dev + cd .. + git clone --single-branch --branch OpenSSL_1_1_1-stable --depth 1 https://github.com/openssl/openssl.git + cd openssl + ./Configure linux-x86_64 no-shared + make + cd .. + git clone https://github.com/armornetworkdev/lmdb.git + - name: CMAKE + working-directory: ${{github.workspace}} + shell: bash + run: | + mkdir build + cd build + cmake .. + + - name: Build + working-directory: ${{github.workspace}}/build + shell: bash + run: | + make + + - name: Test + working-directory: ${{github.workspace}}/bin + shell: bash + run: | + ./armord --version + ./walletd --version diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index 42fd29d8..e0f836a0 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ xcuserdata /bytecoin.cbp *swp WorkspaceSettings.xcsettings +*.user # cmake specific CMakeLists.txt.user* diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index 4c8e439f..8221dd45 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,10 +2,10 @@ # Licensed under the GNU Lesser General Public License. See LICENSE for details. cmake_minimum_required(VERSION 3.0) -project(bytecoin) +project(armornetwork) set(CMAKE_CXX_STANDARD 14) set(CMAKE_C_STANDARD 11) -set(CRYPTONOTE_NAME bytecoin) +set(CRYPTONOTE_NAME armor) add_definitions(-DCRYPTONOTE_NAME=\"${CRYPTONOTE_NAME}\" -DNDEBUG=1) message("SANITIZE adds clang sanitizer options. Examples thread or address,undefined or fuzzer,address,undefined") option(BETTER_DEBUG "Disables optimizations. We do not use standard debug/realease configurations because they change too much" OFF) @@ -21,7 +21,7 @@ else() endif() if(APPLE) - set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11") + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14") endif() if(WIN32) add_definitions(-D_SCL_SECURE_NO_WARNINGS=1 -D_CRT_SECURE_NO_WARNINGS=1 -D_WIN32_WINNT=0x0501) @@ -80,14 +80,14 @@ add_definitions(-Dplatform_USE_SSL=1) file(GLOB SRC_CRYPTO src/crypto/*.cpp src/crypto/*.hpp src/crypto/*.c src/crypto/*.h - src/crypto/bernstein/*.h src/crypto/bernstein/chacha8.c - src/crypto/bernstein/crypto-ops.c - src/crypto/blake/*.h src/crypto/blake/*.c - src/crypto/groestl/*.h src/crypto/groestl/*.c - src/crypto/jh/*.h src/crypto/jh/*.c - src/crypto/keccak/*.c - src/crypto/oaes/*.h src/crypto/oaes/*.c - src/crypto/skein/*.h src/crypto/skein/*.c + src/crypto/bernstein/*.h src/crypto/bernstein/chacha8.c + src/crypto/bernstein/crypto-ops.c + src/crypto/blake/*.h src/crypto/blake/*.c + src/crypto/groestl/*.h src/crypto/groestl/*.c + src/crypto/jh/*.h src/crypto/jh/*.c + src/crypto/keccak/*.c + src/crypto/oaes/*.h src/crypto/oaes/*.c + src/crypto/skein/*.h src/crypto/skein/*.c ) if(CRYPTO128) message(STATUS "Fast crypto using int128 selected - do not use for production builds until fully tested") @@ -174,14 +174,14 @@ set(SOURCE_FILES set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/libs") -add_library(bytecoin-crypto ${SRC_CRYPTO}) +add_library(armor-crypto ${SRC_CRYPTO}) if(APPLE) link_libraries(-dead_strip "-framework Foundation") endif() -add_library(bytecoin-core ${SOURCE_FILES}) -target_link_libraries(bytecoin-core bytecoin-crypto ${HID_LIBRARY}) +add_library(armor-core ${SOURCE_FILES}) +target_link_libraries(armor-core armor-crypto ${HID_LIBRARY}) -link_libraries(bytecoin-crypto bytecoin-core) +link_libraries(armor-crypto armor-core) if(NOT WIN32) link_libraries(${LINK_OPENSSL} dl pthread) endif() diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 95d4cf9a..37d1f6f8 --- a/README.md +++ b/README.md @@ -1,10 +1,9 @@ -# Bytecoin +# Armor Network -[![Build Status](https://dev.azure.com/bcndev/bytecoin/_apis/build/status/bytecoin-daemons?branchName=releases/3.5.1)](https://dev.azure.com/bcndev/bytecoin/_build/latest?definitionId=1&branchName=releases/3.5.1) ## About -Welcome to the repository of Bytecoin. Here you will find source code, instructions, wiki resources, and integration tutorials. +Welcome to the repository of Armor. Here you will find source code, instructions, wiki resources, and integration tutorials. Contents * Building on Linux 64-bit @@ -18,55 +17,55 @@ All commands below work on Ubuntu 18.*, other distributions may need different c ### Building with standard options -Create directory `bcndev` somewhere and go there: +Create directory `armor` somewhere and go there: ``` -$> mkdir bcndev -$> cd bcndev +$> mkdir armor +$> cd armor ``` To go futher you have to have a number of packages and utilities. You need at least gcc 5.4. * `build-essential` package: ``` - $bcndev> sudo apt-get install build-essential + $armor> sudo apt-get install build-essential ``` * `libudev`: ``` sudo apt-get install libudev-dev ``` - + * CMake (3.0 or newer): ``` - $bcndev> sudo apt-get install cmake - $bcndev> cmake --version + $armor> sudo apt-get install cmake + $armor> cmake --version ``` If version is too old, follow instructions on [the official site](https://cmake.org/download/). * Boost (1.65 or newer): We use boost as a header-only library via find_boost package. So, if your system has boost installed and set up, it will be used automatically. - Note - there is a bug in `boost::asio` 1.66 that affects `bytecoind`. Please use either version 1.65 or 1.67+. + Note - there is a bug in `boost::asio` 1.66 that affects `armord`. Please use either version 1.65 or 1.67+. ``` - $bcndev> sudo apt-get install libboost-dev + $armor> sudo apt-get install libboost-dev ``` - If the latest boost installed is too old (e.g. for Ubuntu 16.*), then you need to download and unpack boost into the `bcndev/boost` folder. + If the latest boost installed is too old (e.g. for Ubuntu 16.*), then you need to download and unpack boost into the `armor/boost` folder. ``` - $bcndev> wget -c 'https://dl.bintray.com/boostorg/release/1.69.0/source/boost_1_69_0.tar.gz' - $bcndev> tar -xzf ./boost_1_69_0.tar.gz - $bcndev> rm ./boost_1_69_0.tar.gz - $bcndev> mv ./boost_1_69_0/ ./boost/ + $armor> wget -c 'https://boostorg.jfrog.io/artifactory/main/release/1.69.0/source/boost_1_69_0.tar.gz' + $armor> tar -xzf ./boost_1_69_0.tar.gz + $armor> rm ./boost_1_69_0.tar.gz + $armor> mv ./boost_1_69_0/ ./boost/ ``` * OpenSSL (1.1.1 or newer): - Install OpenSSL to `bcndev/openssl` folder. (In below commands use switch `linux-x86_64-clang` instead of `linux-x86_64` if using clang.) + Install OpenSSL to `armor/openssl` folder. (In below commands use switch `linux-x86_64-clang` instead of `linux-x86_64` if using clang.) ``` - $bcndev> git clone --single-branch --branch OpenSSL_1_1_1b --depth 1 https://github.com/openssl/openssl.git - $bcndev> cd openssl - $bcndev/openssl> ./Configure linux-x86_64 no-shared - $bcndev/openssl> make -j8 - $bcndev/openssl> cd .. + $armor> git clone --single-branch --branch OpenSSL_1_1_1b --depth 1 https://github.com/openssl/openssl.git + $armor> cd openssl + $armor/openssl> ./Configure linux-x86_64 no-shared + $armor/openssl> make -j8 + $armor/openssl> cd .. ``` * LMDB @@ -75,26 +74,26 @@ To go futher you have to have a number of packages and utilities. You need at le Difference to official LMDB repository is lifted 2GB database limit if built by MSVC (even of 64-bit machine). ``` - $bcndev> git clone https://github.com/bcndev/lmdb.git + $armor> git clone https://github.com/armornetworkdev/lmdb.git ``` -Git-clone (or git-pull) Bytecoin source code in that folder: +Git-clone (or git-pull) Armor source code in that folder: ``` -$bcndev> git clone https://github.com/bcndev/bytecoin.git +$armor> git clone https://github.com/armornetworkdev/armor.git ``` -Create build directory inside bytecoin, go there and run CMake and Make: +Create build directory inside armor, go there and run CMake and Make: ``` -$bcndev> mkdir -p bytecoin/build -$bcndev> cd bytecoin/build -$bcndev/bytecoin/build> cmake .. -$bcndev/bytecoin/build> make -j8 +$armor> mkdir -p armor/build +$armor> cd armor/build +$armor/armor/build> cmake .. +$armor/armor/build> make -j8 ``` Check built binaries by running them from `../bin` folder ``` -$bcndev/bytecoin/build> ../bin/bytecoind -v +$armor/armor/build> ../bin/armord -v ``` ## Building on Mac OSX @@ -108,42 +107,42 @@ Then open terminal and install CMake and Boost: * `brew install cmake` * `brew install boost` -Create directory `bcndev` somewhere and go there: +Create directory `armor` somewhere and go there: ``` -$~/Downloads> mkdir bcndev -$~/Downloads> cd bcndev +$~/Downloads> mkdir armor +$~/Downloads> cd armor ``` -Git-clone (or git-pull) Bytecoin source code in that folder: +Git-clone (or git-pull) Armor source code in that folder: ``` -$bcndev> git clone https://github.com/bcndev/bytecoin.git +$armor> git clone https://github.com/armornetworkdev/armor.git ``` -Put LMDB source code in `bcndev` folder (source files are referenced via relative paths, so you do not need to separately build it): +Put LMDB source code in `armor` folder (source files are referenced via relative paths, so you do not need to separately build it): ``` -$~/Downloads/bcndev> git clone https://github.com/bcndev/lmdb.git +$~/Downloads/armor> git clone https://github.com/armornetworkdev/lmdb.git ``` -Install OpenSSL to `bcndev/openssl` folder: +Install OpenSSL to `armor/openssl` folder: ``` -$~/Downloads/bcndev> git clone --single-branch --branch OpenSSL_1_1_1b --depth 1 https://github.com/openssl/openssl.git -$~/Downloads/bcndev> cd openssl -$~/Downloads/bcndev/openssl> ./Configure darwin64-x86_64-cc no-shared -mmacosx-version-min=10.11 -$~/Downloads/bcndev/openssl> make -j8 -$~/Downloads/bcndev/openssl> cd .. +$~/Downloads/armor> git clone --single-branch --branch OpenSSL_1_1_1b --depth 1 https://github.com/openssl/openssl.git +$~/Downloads/armor> cd openssl +$~/Downloads/armor/openssl> ./Configure darwin64-x86_64-cc no-shared -mmacosx-version-min=10.11 +$~/Downloads/armor/openssl> make -j8 +$~/Downloads/armor/openssl> cd .. ``` -Create build directory inside bytecoin, go there and run CMake and Make: +Create build directory inside armor, go there and run CMake and Make: ``` -$~/Downloads/bcndev> mkdir bytecoin/build -$~/Downloads/bcndev> cd bytecoin/build -$~/Downloads/bcndev/bytecoin/build> cmake .. -$~/Downloads/bcndev/bytecoin/build> make -j8 +$~/Downloads/armor> mkdir armor/build +$~/Downloads/armor> cd armor/build +$~/Downloads/armor/armor/build> cmake .. +$~/Downloads/armor/armor/build> make -j8 ``` Check built binaries by running them from `../bin` folder: ``` -$bcndev/bytecoin/build> ../bin/bytecoind -v +$armor/armor/build> ../bin/armord -v ``` ## Building on Windows @@ -151,45 +150,45 @@ $bcndev/bytecoin/build> ../bin/bytecoind -v You need Microsoft Visual Studio Community 2017. [Download](https://www.visualstudio.com/vs/) and install it selecting `C++`, `git`, `cmake integration` packages. Run `Visual Studio x64 command prompt` from start menu. -Create directory `bcndev` somewhere: +Create directory `armor` somewhere: ``` -$C:\> mkdir bcndev -$C:\> cd bcndev +$C:\> mkdir armor +$C:\> cd armor ``` Boost (1.65 or newer): - We use boost as a header-only library via find_boost package. So, if your system has boost installed and set up, it will be used automatically. If not, you need to download and unpack boost into bcndev/boost folder. + We use boost as a header-only library via find_boost package. So, if your system has boost installed and set up, it will be used automatically. If not, you need to download and unpack boost into armor/boost folder. -Git-clone (or git-pull) Bytecoin source code in that folder: +Git-clone (or git-pull) Armor source code in that folder: ``` -$C:\bcndev> git clone https://github.com/bcndev/bytecoin.git +$C:\armor> git clone https://github.com/armornetworkdev/armor.git ``` Put LMDB in the same folder (source files are referenced via relative paths, so you do not need to separately build it): ``` -$C:\bcndev> git clone https://github.com/bcndev/lmdb.git +$C:\armor> git clone https://github.com/armornetworkdev/lmdb.git ``` Download amalgamated [SQLite 3](https://www.sqlite.org/download.html) and unpack it into the same folder (source files are referenced via relative paths, so you do not need to separately build it). You need to build openssl, first install ActivePerl (select "add to PATH" option, then restart console): ``` -$C:\bcndev> git clone --single-branch --branch OpenSSL_1_1_1b --depth 1 https://github.com/openssl/openssl.git -$C:\bcndev> cd openssl -$C:\bcndev\openssl> perl Configure VC-WIN64A no-shared no-asm -$C:\bcndev\openssl> nmake -$C:\bcndev\openssl> cd .. +$C:\armor> git clone --single-branch --branch OpenSSL_1_1_1b --depth 1 https://github.com/openssl/openssl.git +$C:\armor> cd openssl +$C:\armor\openssl> perl Configure VC-WIN64A no-shared no-asm +$C:\armor\openssl> nmake +$C:\armor\openssl> cd .. ``` If you want to build 32-bit binaries, you will also need 32-bit build of openssl in separate folder (configuring openssl changes header files, so there is no way to have both 32-bit and 64-bit versions in the same folder): ``` -$C:\bcndev> git clone --single-branch --branch OpenSSL_1_1_1b --depth 1 https://github.com/openssl/openssl.git openssl32 -$C:\bcndev> cd openssl32 -$C:\bcndev\openssl> perl Configure VC-WIN32 no-shared no-asm -$C:\bcndev\openssl> nmake -$C:\bcndev\openssl> cd .. +$C:\armor> git clone --single-branch --branch OpenSSL_1_1_1b --depth 1 https://github.com/openssl/openssl.git openssl32 +$C:\armor> cd openssl32 +$C:\armor\openssl> perl Configure VC-WIN32 no-shared no-asm +$C:\armor\openssl> nmake +$C:\armor\openssl> cd .. ``` -Now launch Visual Studio, in File menu select `Open Folder`, select `C:\bcndev\bytecoin` folder. +Now launch Visual Studio, in File menu select `Open Folder`, select `C:\armor\armor` folder. Wait until CMake finishes running and `Build` appears in main menu. Select `x64-Debug` or `x64-Release` from standard toolbar, and then `Build/Build Solution` from the main menu. @@ -199,21 +198,19 @@ You can build daemons that use SQLite istead of LMDB on any platform by providin You may need to clean 'build' folder, if you built with default options before, due to cmake aggressive caching. ``` -$bytecoin/build> cmake -DUSE_SQLITE=1 .. -$bytecoin/build> time make -j8 +$armor/build> cmake -DUSE_SQLITE=1 .. +$armor/build> time make -j8 ``` ## Building on 32-bit x86 platforms, iOS, Android and other ARM platforms -Bytecoin works on 32-bit systems if SQLite is used instead of LMDB (we've experienced lots of problems building and running with lmdb in 32-bit compatibility mode, especially on iOS). - -We build official x86 32-bit version for Windows only, because there is zero demand for 32-bit version for Linux or Mac. +Armor works on 32-bit systems if SQLite is used instead of LMDB (we've experienced lots of problems building and running with lmdb in 32-bit compatibility mode, especially on iOS). -Building source code for iOS, Android, Raspberry PI, etc is possible (we have experimental `bytecoind` and `walletd` running on ARM64 iPhone) but requires major skills on your part. __TBD__ +Building source code for iOS, Android, Raspberry PI, etc is possible (we have experimental `armord` and `walletd` running on ARM64 iPhone) but requires major skills on your part. __TBD__ ## Building on Big-Endian platforms -Currently bytecoin does not work out of the box on any Big-Endian platform, due to some endianess-dependent code. This may be fixed in the future. If you wish to run on Big-Endian platform, please contact us. +Currently armor does not work out of the box on any Big-Endian platform, due to some endianess-dependent code. This may be fixed in the future. If you wish to run on Big-Endian platform, please contact us. ## Building with parameters diff --git a/ReleaseNotes.md b/ReleaseNotes.md old mode 100644 new mode 100755 index c5bdad34..c510ed61 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,422 +1,9 @@ ## Release Notes -### v3.5.1 (Beryl) +### v0.0.3 + - Seed nodes updated + - Check points updated -- Fixed bug when `walletd` will not sync after being unable to contact `bytecoind` for a long time. -- Fixed rare bug when exported view wallet contained wrong view secrets signature. -- Fixed bug when instead of error message, empty send proof was generated for address not used in particular transaction. Such proofs are invalid so this did not lead to any security issues. -- Fixed bug when `walletd` sometimes included no block information for unlocked outputs in `get_transfers` JSON RPC call. This affected only clients who inspected per-block `unlocked_transfers`, but not `unlocked_transfers` array returned for the request as a whole. -- Fixed problem when during `sync_blocks` excess block was returned at the start of the response. This could lead to endless sync loop if this block size was larger that `max_size` limit set by caller, because only that block would be returned again and again. -- Removed addresses from wallet cache for amethyst wallets -- `walletd` can now export view-only wallet without ability to view outgoing addresses from a view-wallet with such capability. -- `tx_pool_version` is no more reset to `0` on block change, but steadily increases on each pool modification. Ir prevents some very rare race conditions between APi users and daemons. +### v0.0.2 -*Security-related changes* -- Lots of code reorganisation to remove false positives from clang static analyser. -- Several potential undefined behaviours fixed, related to forgetting to initialise values of primitive types in templates. -- Potential floating-point undefined behaviour fixed. -- Several additional checks added to P2P commands parsing. -- Potential crash in groestl hash implementation fixed. -- Connections using legacy P2P version (and legacy commands) prohibited, effectively enabling much stricter consensus rules for P2P (such as hard limits on size of all commands), hardening against potential attacks. -- Security options (non-executable stack, position-independent-binary, non-writable relocation table) for binaries enabled by default on Linux. -- Tiny memory leak fixed. - -*Incompatible API changes* -- `get_transfers` and `get_transaction` `walletd` methods do not return outputs in transfers by default (they are large and very rarely needed). If you need outputs, you should set `need_outputs` parameter to true. -- `outputs` field is now optional in transfer in all contexts. -- `public_key` field is now optional in transaction in all contexts (motivation - amethyst transactions contain no public key) -- `extra` field is now optional in transaction in all contexts (motivation - after removing public key from extra, it is empty for most transactions) - -### v3.5.0 (Beryl) - -*API tweaks* - -- All numbers in JSON RPC requests can be sent as strings, "123" instead of 123. This helps integration with JavaScript. -- All JSON RPC requests get optional boolean "numbers_as_strings" parameter (default false). If set to true, all numbers will be returned as strings. This helps integration with JavaScript. - -### v3.4.5 (Amethyst) - -- Tiny fixes in mining-related code. All miners are advised to update. - -*API tweaks* -- In `get_transfers` response, when filtering by address, filtering does not remove transfers from transactions, only returns less transactions -- In `check_sendproof` error response, hash of referenced transaction is returned if proof is successfully parsed -- In `check_sendproof` errors `ADDRESS_NOT_IN_TRANSACTION (-204)` and `ADDRESS_FAILED_TO_PARSE (-4)` removed, `PROOF_WRONG_SIGNATURE (-203)` will be reported instead. -- `walletd` methods which do request to `bytecoind` - `create_transaction`, `send_transaction`, `create_sendproof` will now return special error `BYTECOIND_REQUEST_ERROR (-1003)` instead of `INTERNAL_ERROR (-32603)` when json RPC call to `bytecoind` fails. - -*API deprecations (will be removed in future)* -- In `get_transfers` response, `unlocked_transfers` for range of blocks deprecated, unlocked transfers are returned in corresponding blocks. -- In `create_sendproof` request/response, `addresses/sendproofs` fields are deprecated, use `address/sendproof` instead. If using `address` field and proof canno be created, json RPC error `ADDRESS_NOT_IN_TRANSACTION (-204)` will be returned, instead of empty proof, as it was before. - -### v3.4.4 (Amethyst) - -- `walletd` can now sync most of the blockchain from static files (tremendously increasing efficiency for public nodes), reverting to RPC only for the (small) part of blockchain after last hard checkpoint. -- Fixed bug when during wallet sync some transactions from memory pool were requested and processed more than once - -### v3.4.3 (Amethyst) - -- In `get_transfers` `walletd`'s method error is returned if `from_height` is larger than `to_height` or top block height. -- `WALLET_FILE_EXISTS (209)` is correctly returned when `walletd` is instructed to overwrite an existing wallet. -- Fixed a bug when wrong error message was displayed when passing some invalid addresses to `walletd`'s `create_transaction` RPC method. -- LMDB virtual memory usage by `bytecoind` and `walletd` reduced from fixed 512Gb to approx. actual blockchain database/wallet cache size. -- `walletd` will not undo sync progress, if connected node is behind wallet state and behind latest hard checkpoint. It will wait for a node to advance to a checkpoint. -- Wallet cache now takes much less space, especially for wallets with small number of transactions. -- For all TCP sockets `keep_alive` option is now set after they are created (with default timeouts for each system, common value is 2 hours), solving very rare bug when there would be no reply to long poll ever for external services (like block explorers) calling from remote machines. -- All paths now subject to substitution of `~` (Mac & Linux) and `%appdata%` (Windows). Also, on Linux and Max backslash is no more considered path separator. - -*API tweaks* -- JSON numbers are interpreted according to spec throughout API, for example 10.01E2 is now good value for height (1001). This helps integration with some weird languages. -- Better error messages throughout API when required parameters are not specified. -- More strict JSON RPC - excess fields on top level are no more allowed in requests. -- `bytecoind`'s binary version of `sync_blocks` now uses separate zero overhead response to save traffic during sync. - -*Incompatible API changes* -- `bytecoind`'s `getblocktemplate`, `submitblock` and JSON versions of `sync_blocks` and `sync_mempool` now require private authorization. This helps with preventing excess load on public nodes. -- deprecated field `outs_count` in `bytecoind.get_random_outputs` removed. - -### v3.4.2 (Amethyst) - -- Fixed merge mining related bug affecting blocks version 4 (amethyst). All miners not upgraded to 3.4.2 at the moment of consensus update will produce broken blocks. -- Fixed crash when disconnecting Ledger while scanning blockchain. -- Fixed behavior of the `get_transfers` `walletd`'s method when transactions from a memory pool are wrongly returned for some `from_height` and `to_height` values. - -*Incompatible API changes* -- In response to the `get_wallet_info` `walletd`'s method, boolean field `amethyst` changed to string `wallet_type` - -### v3.4.2-beta-20190412 - -- Fixed a stagenet voting bug. - -### v3.4.2-beta-20190411 - -- Fixed problem when `bytecoind` stops responding via JSON RPC API. -- Tweaked random output distribution for mixins. -- The `walletd` daemon now better utilizes CPU during sync (cores use 100%, if available). -- During mining, the `bytecoind` daemon now prefers blocks received via `submit_block` API to other blocks, if difficulty are equal. This will slightly increase mining profitability for lucky miners. -- Added back `create_transaction` optimization for large wallets which was accidentally removed in version 3.4.1. -- Fixed bug when transaction size is `0` in all `walletd` API calls. -- Fixed bug when transaction timestamp is `0` in `get_transaction` of `bytecoind` API call for transaction, if it has been already included in the blockchain. -- Transaction fields `prefix_hash` and `inputs_hash` are now correctly set in various `bytecoind` API calls, if `need_redundant_data` is set. -- Improved command line processing in `walletd`, especially if wrong combination of options specified. -- Trezor and Ledger early support in `walletd`. - -*Incompatible API changes* -- Deprecated `binary_size` field removed from transaction in all contexts. Please use the `size` field. - -### v3.4.1 (Amethyst) - -- New cryptography reviewed, some important tweaks added - thanks for all feedback to those who contributed. -- Derivation paths of wallet secrets modified. Now dishonest modification of any secret in view-only wallet is immediately clear to auditor. -- Output seed generation simplified. -- Proof of sH ~ H contained in view-only wallet is simplified. - -*API additions* - -- Added `has_view_secret_key` field in the `get_wallet_info` method of `walletd`. - -### hardware-wallets-alpha-20190214 - -- Added an early support for hardware wallets. -- Fully working Trezor Model T prototype. -- Partial support for Ledger Nano. - -*Current Limitations* -- If you disconnect a hardware wallet while `walletd` is running, it will immediately crash. -- Works in the stagenet only. - -### v3.4.0 (Amethyst) - -- Sendproofs are now in base58 format, which eases copying and sharing. -- New addresses now start from `bcnZ` prefix. - -*Command line changes/additions* - -- New walletd command-line parameter `--wallet-type` to create legacy wallets (`--create-wallet` by default creates new HD wallet). - -*API removal* - -- Removed `amethyst_only` flag in the `get_random_outputs` bytecoind method. - - -### v3.4.0-beta-20190123 - -*Strong support for audit-compatible wallets* - -- All new unlinkable addresses are now auditable, so separate auditable address type removed from system. -- View-only HD wallet is now guaranteed to have the same balance as original wallet. So owner of HD wallet cannot spend any funds in a way that view-only version of the same wallet does not see the fact. -- If view-only HD wallet was exported with --view-outgoing-addresses, it can also see all destination addresses in transactions that spend funds. If spender is sending to some address, he cannot make auditor see different destination address for this transaction. If spender is using sophisticated "out-of-blockchain shared secret" fraud, auditor will see random address, and spender will not be able to provide valid sendproof for this transaction. - -*Consensus update (hard fork)* -- New crypto for legacy addresses (unlinkable-inspired), which prevents "burning bug" attacks on crypto level. This is important because such attacks cannot be reliably fixed on operational level. - -*API additions* -- `amethyst_only` flag in `get_random_outputs` bytecoind method. - -*Incompatible API changes (likely to affect only developers of block explorers)* - -- In all raw block objects `output_indexes` renamed to `stack_indexes`. - -### v3.4.0-beta-20181218 - -- Signatures are now fully prunable (but not yet pruned) via modification to transaction hash calculations. -- A view-only wallet now shows address balance even for non-auditable unlinkable addresses, but only if sender follows the protocol. If in doubt about sender's fair play, auditable addresses should be used instead. -- A view-only wallet can now be exported with or without ability to view transaction destination addresses. -- `bytecoind` will not automatically look for `blocks.bin` anywhere. If you need to import blocks from file, use `--import-blocks=` command line parameter. -- `bytecoind` command line parameters `--ssl-certificate-pem-file`, `--ssl-certificate-password` removed, use ngnx in https proxy mode! - -### v3.4.0-beta-20181212 - -*Consensus update (hard fork)* -- The release starts immediate voting in the stagenet. Voting in the mainnet will start when v3.4.0 is released. -- Introduce new unlinkable addresses, stored in new HD wallet. Single mnemonic is enough to restore all wallet addresses. -- Destination addresses can now be derived from blockchain with wallet secrets, so saving history is now unnecessary. -- Greatly simplified maximum block size calculations. Miners will now explicitly vote for maximum block size (up to hard limit of 2 MB), depending on how many expensive transactions are in memory pool. Reward penalties are removed and most other unnecessary checks on block/transactions sizes are also removed from consensus. -- New HD wallet is encrypted with chacha20 with salt (major improvement to previous wallet format) -- New auditable addresses, guaranteed to always have balance exactly equal to what view-only version of the same wallet shows (useful for public deposits). -- Signatures are now half size. -- The requirement that coinbase transactions are locked for 10 blocks is removed from consensus. -- Creating 6-digit dust (or other not round output amounts) are now prohibited by consensus rules. -- Minimum anonymity is now 3 (4 output references per input). This does not apply to dust or not round outputs. -- `bytecoind` now calculates output obfuscation value, and does not use less-than-ideal outputs for mix-in - -*Command line changes/additions* -- New walletd command-line parameter to set creation time when importing keys or mnemonic (which have no inherent timestamp) -- New walletd command-line parameter to generate mnemonics -- New walletd command-line parameter to create unlinkable wallet from mnemonics -- New walletd command-line parameter to enable getting secrets bia JSON RPC API - -*Specific API improvements* -- By default, getting secrets via JSON RPC API is disabled. -- New walletd method 'get_wallet_records' with optional 'create' parameter can be used to get (creating if needed) wallet records from linkable wallet -- New walletd method `set_address_label` to set labels for addresses (labels are returned by `get_wallet_records`) -- New error code `TOO_MUCH_ANONYMITY` (`-305`) can be returned from `create_transaction`. - -*API deprecations (will be removed in version 3.5.0)* -- `walletd` method `get_addresses` is marked as deprecated, use `get_wallet_records` instead. -- `walletd` method `get_view_key_pair` is marked as deprecated, use `get_wallet_info` with `need_secrets` set to true instead. -- `walletd` method 'create_transaction' has 'save_history' and 'save_history_error' deprecated, because history is now always implicitly saved to blockchain. -- `next_block_effective_median_size` renamed to `recommended_max_transaction_size` with `next_block_effective_median_size` deprecated. - -*Incompatible API changes* -- `parent_block` is renamed to `root_block` in all contexts without deprecation, due to widespread confusion. - -*Improvements to P2P protocol to handle large network load* -- Header relay instead of block body relay. In most cases receiver will reasemble block from memory pool. In rare case when this is not possible, the block body will be requested. -- Transaction description relay instead of transactions body relay. Only new transactions will be requested. Transaction descriptions contain most recent referenced block hash, so that receiver can easily distinguish between "wrong signatures due to malicious intent" and "wrong signatures due to chain reorganisations" -- Incremental memory pool sync with cut-off limit by fee/byte. Allows pools with huge assymetry in size to quickly get into stable state. - -*Other changes* -- Memory pool size increased to 4 MB. -- `walletd` will automatically rebuild wallet cache after upgrade to this version. This can take long time for large wallets. - -### v3.3.3 - -- Fixed bug when `walletd` fails to create transactions for certain coins. - -### v3.3.2 - -- Now all folders we get from user/system are normalized by removing excess slashes from the tail - -### v3.3.1 - -- The `create_transaction` method can now create transactions with fee < 0.01 BCN iff both `fee_per_byte` and transaction size are small enough. -- In the `create_transaction` method, if `any_spend_address` is set to true, leaving `change_address` empty now sets it to first wallet address. -- Added amounts to the message of the `TRANSACTION_TOO_BIG` error so that you see how much you can actually send (with desired or zero anonymity). -- Added a new new flag `subtract_fee_from_amount` to the `create_transaction` method to indicate subtracting fee from receivers. -- Tweaked the distribution of mix-in outputs returned by the `get_random_outputs` method to make it . -- Fixed error in the `getblocktemplate` and `get_block_template` methods which returned wrong reserved_offset. - -### v3.3.0 - -*Consensus update (hard fork)* - -- Voting starts immediately, once 90% of mined blocks contain votes for update, the update height will be automatically selected so that consensus update will happen approximately 2 weeks after that. -- Market fees - any transaction fee including `0` is now legal for all transactions. Miners will increase block size only if it is profitable for them in a short run. - -*General improvements* - -- Better priority and exclusive nodes logic. -- Seed nodes are now contacted approximately once per day (greatly helps to catch up after `bytecoind` is started for users who run it after delay of several weeks or more). -- Binary methods now share single access point `/binary_rpc`. -- Code for consensus upgrade voting correctly counts votes on both main chain and each side chain. -- Limited on incoming connections (default is 100). -- Fixed ignored external port on peer handshake (made connects through exposed non-standard ports to nodes behind NAT impossible). -- Groestl hash function is updated from the official source. -- Keccak permutation function is updated from the official source. -- `bytecoind` never searches for `blocks.bin` and `blockindex.bin` outside the data folder. -- now when you specify `--p2p-bind-address`, but not `--p2p-external-port`, p2p external port will be set to p2p bind port. When you wish NAT tunneling, good practice is to specify both. - -*Command line changes/additions* - -- Paranoid mode to check every byte of blockchain when downloading (usually checks only blocks beyond the last checkpoint). -- *Warning:* Now `walletd` exits by default after `--create-wallet` and `--set-password` operations. This change can break your scripts. If you need the wallet running after those commands, you can add `--launch-after-command` parameter -- Now you can use `--set-password` with `--export-view-only` and `--backup-wallet-data`, to encrypt result wallet with a different password. -- Fixed bug with `walletd` not returning `api::WALLETD_BIND_PORT_IN_USE` error code when the JSON API port is in use and using inproc `bytecoind`. -- Fixed bug with `bytecoind` not returning `api::BYTECOIND_BIND_PORT_IN_USE` error code when the JSON API port is in use. -- `walletd` now prints address after creation of wallet. -- `walletd` now prints deprecation warning when using inproc `bytecoind`. -- `walletd` now binds to port `9070` on testnet and `10070` on stagenet resp. by default. - -*General API improvements* - -- Optimisation of JSON RPC calls (2x speed up on very large responses). -- Made the `jsonrpc` argument mandatory with value "2.0" in all JSON RPC calls according to the spec. -- JSON RPC `id` is required now according to spec. -- JSON RPC error's additional data moved into `data` object inside the `error` object according to spec. -- Now any field in requests that daemons do not understand will be reported as a error. -- Much better error handling, more specific error codes. - -*Specific API improvements* - -- New `get_block_header` method for blockchain structure inspection (to replace `getblockheaderbyhash`, `getblockheaderbyheight`, and `getlastblockheader` legacy methods). -- New `get_wallet_info` method. -- New `VIEW_ONLY_WALLET` (`-304`) error code, returned from `create_transaction`. -- In methods supporting longpoll (`get_statu`s and `get_block_template`) all longpoll arguments are now optional. So, for example, if you are interested in `outgoing_peer_count` only, you can specify only `outgoing_peer_count` in request and get response when `outgoing_peer_count` changes. Changes to other fields will not trigger response to longpoll. -- New `ADDRESS_FAILED_TO_PARSE` (`-4`) and `ADDRESS_NOT_IN_WALLET` (`-1002`) error codes, returned from lots of methods -- New fields in get_addresses request/response to iterate through list of addresses -- Now `top_block_timestamp_median` returned correctly from get_status JSON RPC methods. -- New `need_signatures` fields in APIs returning raw transactions. -- `check_sendproof` now returns values from sendproof in response if proof is valid. -- All methods return new correct values for `block_size` and `transactions_cumulative_size`. -- `get_raw_block` and `get_block_header` now return `orphan_status` and `depth` (consistent with `height_or_depth` fields where top block is `-1`). -- `get_random_amounts` has no more depth limit of 128 block (distribution would be skewed a bit for very large depths). -- `get_statistics` response now includes much more information. -- `submit_block` now returns `block_header` in result. -- All `transfer` objects now have `transaction_hash` field - especially useful when processing `unlocked_transfers` in result of `get_transfers` method. - -*API deprecations (will be removed in version 3.4.0)* - -- In all `output` and `transaction` objects `unlock_time` is deprecated (renamed to `unlock_block_or_timestamp`). -- In all `output` objects `global_index` deprecated (renamed to `index`). -- In `get_random_outputs` request `outs_count` is deprecated (renamed to `output_count`). -- In `get_transfers` request `desired_transactions_count` is deprecated (renamed to `desired_transaction_count`). -- In all `transaction` objects 'binary_size' is deprecated (renamed to `size`). - -*Incompatible API changes* - -- `get_raw_transaction` method now returns json error `-5` if transaction not found. -- Deprecated `prev_hash` field remains only in result of legacy methods (`getblockheaderbyhash`, `getblockheaderbyheight`, and `getlastblockheader` legacy methods), use 'previous_block_hash' instead. -- Deprecated `total_fee_amount` field remains only in result of legacy methods (`getblockheaderbyhash`, `getblockheaderbyheight`, and `getlastblockheader`), use `transactions_fee` instead. -- Deprecated `transactions_cumulative_size` field remains only in result of legacy methods (`getblockheaderbyhash`, `getblockheaderbyheight`, and `getlastblockheader`), use `transactions_size` instead. - -*Incompatible API changes (likely to affect only developers of block explorers)* - -- In all raw block objects `global_indices` renamed to `output_indexes`. -- In all raw transaction objects `vin`, `vout` renamed to `inputs`, `outputs` resp. -- In all raw output objects `key` renamed to `public_key`. -- In all raw output objects `target` object removed and all its fields moved into raw output object. -- In all raw coinbase input objects `block_index` renamed to `height`. -- In all raw header objects (including `parent_block`) `miner_tx`, `base_transaction_branch` renamed to `coinbase_transaction`, `coinbase_transaction_branch` resp. -- In all raw input and raw output objects, `tag`:`ff` renamed to `type`:`coinbase` and `tag`:`02` renamed to `type`:`key`. - -*Testnet/Stagenet related* - -- New command line parameter `--net=test|stage|main` configures daemons for testnet, stagenet, or mainnet resp. -- For testnet time multiplier can now be set to speed up all processes 10x, 100x or even more. -- When participating in testnet or stagenet, `bytecoind` now uses UDP Multicast to announce/discover other bytecoind nodes in local network. Thus in most local networks testnet will self-assemble without seed nodes. In mainnet multicasts are disabled due to anonymity concerns. -- Testnet/Stagenet now have fixed 1MB max block size limit. - -### v3.2.4 - -- Added the testnet functionality. -- Fixed `WRONG_BLOCKCHAIN` problem when walletd ends up in a state where it could not sync with `bytecoind`. -- Put a stop to infinite attempts to download blockchain from nodes lagging behind. - -### v3.2.3 - -- Fixed issues in SQLite logic in x86-32 daemons. -- Fixed a bug in the downloader, which hinders normal downloading blocks. - -### v3.2.2 - -- Fixed an output bufferization issue in the `bytecoind` daemon. -- Fixed a rare downloader's crash on Windows. - -### v3.2.1 - -- Fixed a severe bug in the downloader. - -### v3.2.0 - -- *Warning:* This version uses different format of `bytecoind` database and `walletd` caches, they will be upgraded to the new format on a first start of daemons. Prepare for downtime of up to 2 hours depending on your wallet size and computer performance. -- __API change:__ Renamed methods `create_send_proof` and `check_send_proof` to `create_sendproof` and `check_sendproof` respectively (along with input parameter `send_proof` that became `sendproof`). -- Fixed minor bugs found in the beta release. - -### v3.2.0-beta-20180723 - -- *Warning:* This version uses different format of `bytecoind` database and `walletd` caches, they will be upgraded to the new format on a first start of daemons. Prepare for downtime of up to 2 hours depending on your wallet size and computer performance. -- Reworked the wallet cache storage to use 3x less space and run 2x faster. -- Intoduced the 'payment queue' which stores and resends all sent transactions until they are successfully confirmed. This fixes issues with sent transactions lost due to chain reorganizations under high loads. -- Changed the logic of the `send_transaction` method: It never returns an error, its result is always `broadcast` because all transactions are first stored in the payment queue and later sent for sure. -- Improved the downloader to reduce sync times. -- Made the `params` argument optional in all JSON RPC calls according to the spec. -- Improved error handling in the `create_transaction` and `send_transaction` methods (distinct error codes for common errors). -- Fixed issue when requests to `walletd` with address is not in the wallet (it now fails with an appopriate error). -- Changed the mechanism of the memory pool size adjustment to give miners more freedom in selecting transactions for including in blocks. -- The `walletd` command line parameter `--backup-wallet` is renamed to `--backup-wallet-data` and now it makes a hot backup of the wallet cache, wallet history, and payment queue in bulk (backward compatibility is maintained). -- Extended the number of bits of the cumulative difficulty parameter (it is now 128 bits). -- Made entering passwords in terminals/consoles invisible on all major platforms. -- Allowed entered passwords to contain Unicode characters on Windows (not recommended though). -- Changed the logic of the `create_addresses` method when called with at least one existing spend key and without setting `creation_timestamp` (or setting it to `0`). `walletd` will perform rescan of the whole blockchain in this case. -- Added a better error message when `walletd` fails to be authenticated at `bytecoind`. -- Started versioning binary API methods for better detection of changes. - -### v3.1.1 - -- Added `--backup-blockchain` `--backup-wallet` command-line flags to `bytecoind` and `walletd` resp. to hot-copy blockchain and wallet data (wallet file and wallet cache). -- Fixed behavior of the `walletd`'s methods such as `get_balance`, which until now returned zero balance for addresses not belonging to the opened wallet file. - -### v3.1.0 - -- Updated `README` in the part of linking with `boost` libraries to prevent using inappropriate versions. -- __API change:__ Renamed field `added_bc_transactions` to `added_raw_transactions` in response of the `sync_mem_pool` method. -- __API change:__ Renamed fields `bc_header` to `raw_header`, `bc_transactions` to `raw_transactions` in response of the `sync_blocks` method. -- __API addition:__ Added the `get_raw_transaction` method to the `bytecoind` API to get a transaction by its hash. -- __API addition:__ Added the `prevent_conflict_with_transactions` field to the `create_transaction` `walletd`'s method to be used by resilient payout queues. -- Speeded up memory pool to handle large transaction load. -- Fixed rare bug in `bytecoind` when less than possible transactions were included in block for mining during large transaction load. -- Fixed rare bug in `bytecoind` when cumulative difficulty of the block was calculated incorrectly, leading to increased orphan block percentage. (`bytecoind` will now perform quickcheck on start once for all exisitng blockchain database, fixing all differences.) -- Fixed rare bug in `bytecoind` when it stopped accepting new P2P connections or stopped answering API calls under high transaction load. - -### v3.0.4 - -- Made early fixes to downloader to prevent long lagging behind. - -### v3.0.3 - -- Fixed consensus bug. - -### v3.0.2 - -- __API change:__ In `create_transaction`, `spend_address` parameter of type `string` is changed to `spend_addresses` of type `[]string`. This change is likely to affect only Web wallets developers. -- __API change:__ In `sync_mem_pool`, `added_binary_transactions` of type `string` is changed to `added_bc_transactions` of type `bytecoin::TransactionPrefix`. This change breaks compatilibilty between new and old `walletd` and `bytecoind`, so make sure they are both the same version. - -### v3.0.1 - -- Added `walletd` option `--export-keys` to export keys in legacy format (for example, to print on paper and put in a vault). -- Changed logic of how `walletd` truncates cache in old wallet files: On writable media, it now tries to do that right after opening. -- Fixed wallet state undo logic, which rarely lead to sync crashes/stucks in version 3.0.0. -- Added test wallets for import/export testing. - -### v3.0.0 - -- Added HTTPS support between walletd and bytecoind. -- Added generating and checking send proofs. -- Added SQLite database support as an alternative to LMDB. -- Added several legacy bytecoind RPC API methods for miners. - -### v3.0.0-beta-20180219 - -- Reworked creating transactions with 100,000+ unspent outputs to make it much faster. -- Fixed rare crashes of `bytecoind` while downloading blockchain. -- Fixed stuck dowloading from misbehaving nodes. -- Added early support of JSON-RPC API basic authentification that prevents CSRF attacks. -- Added (experimental) support of 32-bit platforms. - -### v3.0.0-beta-20180206 - -- Project is moved to the new public GitHub repository. -- Added `walletd` option `--export-keys` to export keys in legacy format (for example, to print on paper and put in a vault). -- Changed logic of how `walletd` truncates cache in old wallet files: On writable media, it now tries to do that right after opening. -- Fixed wallet state undo logic, which rarely lead to sync crashes/stucks in version 3.0.0. -- Added test wallets for import/export testing. + - Initial release diff --git a/azure-pipelines.yml b/azure-pipelines.yml old mode 100644 new mode 100755 index fae7501c..bbfb8c44 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -30,7 +30,7 @@ jobs: ####################### Linux ####################### - job: Linux pool: - vmImage: ubuntu-16.04 + vmImage: ubuntu-18.04 steps: - checkout: none @@ -46,7 +46,7 @@ jobs: displayName: Install libudev - script: | - mkdir bytecoin && cd bytecoin + mkdir armor && cd armor git init git remote add origin https://user:$(GithubPAT)@github.com/$(daemonsRepo) git fetch --depth 1 origin $(Build.SourceBranch) @@ -54,12 +54,12 @@ jobs: displayName: Clone daemons code - script: | - wget -c 'https://dl.bintray.com/boostorg/release/1.69.0/source/boost_1_69_0.tar.gz' + wget -c 'https://boostorg.jfrog.io/artifactory/main/release/1.69.0/source/boost_1_69_0.tar.gz' mkdir boost && tar -xzf ./boost_1_69_0.tar.gz --directory boost --strip-components=1 displayName: Fetch boost - script: | - git clone --single-branch --depth 1 https://github.com/bcndev/lmdb.git + git clone --single-branch --depth 1 https://github.com/armornetworkdev/lmdb.git displayName: Clone LMDB - script: | @@ -71,16 +71,16 @@ jobs: displayName: Build OpenSSL - script: | - mkdir bytecoin/build && cd bytecoin/build + mkdir armor/build && cd armor/build cmake .. && make -j$(nproc) displayName: Build daemons - script: | - zip -v -j $(Build.ArtifactStagingDirectory)/$(System.TeamProject)-daemons-$(Build.SourceBranchName)-linux64.zip bytecoin/bin/bytecoind bytecoin/bin/minerd bytecoin/bin/walletd + zip -v -j $(Build.ArtifactStagingDirectory)/$(System.TeamProject)-daemons-$(Build.SourceBranchName)-$(TagName)-linux64.zip armor/bin/armord armor/bin/minerd armor/bin/walletd displayName: Zip daemons - script: | - zip -v -r $(Build.ArtifactStagingDirectory)/$(System.TeamProject)-daemons-$(Build.SourceBranchName)-linux64-crypto.zip bytecoin/libs/libbytecoin-crypto.a bytecoin/src/* + zip -v -r $(Build.ArtifactStagingDirectory)/$(System.TeamProject)-daemons-$(Build.SourceBranchName)-$(TagName)-linux64-crypto.zip armor/libs/libarmor-crypto.a armor/src/* displayName: Zip artifacts for future desktop build - task: PublishBuildArtifacts@1 @@ -93,25 +93,21 @@ jobs: ####################### Macos ####################### - job: Mac pool: - vmImage: macOS-10.13 + vmImage: macOS-10.14 variables: - MACOSX_DEPLOYMENT_TARGET: 10.11 + MACOSX_DEPLOYMENT_TARGET: 10.14 condition: | - and( - succeeded(), - or( - startsWith(variables['build.sourceBranch'], 'refs/heads/releases/'), - startsWith(variables['build.sourceBranch'], 'refs/tags/') - )) + succeeded() steps: - checkout: none - script: | - brew install boost - displayName: Install boost from Homebrew + wget -c 'https://boostorg.jfrog.io/artifactory/main/release/1.69.0/source/boost_1_69_0.tar.gz' + mkdir boost && tar -xzf ./boost_1_69_0.tar.gz --directory boost --strip-components=1 + displayName: Install boost - script: | - mkdir bytecoin && cd bytecoin + mkdir armor && cd armor git init git remote add origin https://user:$(GithubPAT)@github.com/$(daemonsRepo) git fetch --depth 1 origin $(Build.SourceBranch) @@ -119,7 +115,7 @@ jobs: displayName: Clone daemons code - script: | - git clone --single-branch --depth 1 https://github.com/bcndev/lmdb.git + git clone --single-branch --depth 1 https://github.com/armornetworkdev/lmdb.git displayName: Clone LMDB - script: | @@ -131,16 +127,16 @@ jobs: displayName: Build OpenSSL - script: | - mkdir bytecoin/build && cd bytecoin/build + mkdir armor/build && cd armor/build cmake .. && make -j displayName: Build daemons - script: | - zip -v -j $(Build.ArtifactStagingDirectory)/$(System.TeamProject)-daemons-$(Build.SourceBranchName)-macos.zip bytecoin/bin/bytecoind bytecoin/bin/minerd bytecoin/bin/walletd + zip -v -j $(Build.ArtifactStagingDirectory)/$(System.TeamProject)-daemons-$(Build.SourceBranchName)-$(TagName)-macos.zip armor/bin/armord armor/bin/minerd armor/bin/walletd displayName: Zip daemons - script: | - zip -v -r $(Build.ArtifactStagingDirectory)/$(System.TeamProject)-daemons-$(Build.SourceBranchName)-macos-crypto.zip bytecoin/libs/libbytecoin-crypto.a bytecoin/src/* + zip -v -r $(Build.ArtifactStagingDirectory)/$(System.TeamProject)-daemons-$(Build.SourceBranchName)-$(TagName)-macos-crypto.zip armor/libs/libarmor-crypto.a armor/src/* displayName: Zip artifacts for future desktop build - task: PublishBuildArtifacts@1 @@ -155,12 +151,7 @@ jobs: pool: vmImage: vs2017-win2016 condition: | - and( - succeeded(), - or( - startsWith(variables['build.sourceBranch'], 'refs/heads/releases/'), - startsWith(variables['build.sourceBranch'], 'refs/tags/') - )) + succeeded() variables: vsPath: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise vsCMakeDir: $(vsPath)\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin @@ -173,17 +164,12 @@ jobs: opensslConfig: VC-WIN64A generatorName: Visual Studio 15 2017 Win64 arch: 64 - win32: - opensslDir: openssl32 - opensslConfig: VC-WIN32 - generatorName: Visual Studio 15 2017 - arch: 32 steps: - checkout: none - bash: | - curl -O http://strawberryperl.com/download/5.28.1.1/strawberry-perl-5.28.1.1-64bit-portable.zip - 7z x strawberry-perl-5.28.1.1-64bit-portable.zip -ostrawberry-perl + curl -O https://strawberryperl.com/download/5.28.2.1/strawberry-perl-5.28.2.1-64bit-portable.zip + 7z x strawberry-perl-5.28.2.1-64bit-portable.zip -ostrawberry-perl displayName: Install ActivePerl (required to build OpenSSL) - bash: | @@ -192,7 +178,7 @@ jobs: displayName: Install Jom - bash: | - mkdir bytecoin && cd bytecoin + mkdir armor && cd armor git init git remote add origin https://user:$(GithubPAT)@github.com/$(daemonsRepo) git fetch --depth 1 origin $(Build.SourceBranch) @@ -200,13 +186,13 @@ jobs: displayName: Clone daemons code - bash: | - curl -L -O https://dl.bintray.com/boostorg/release/1.69.0/source/boost_1_69_0.zip - 7z x boost_1_69_0.zip + curl -L -O https://boostorg.jfrog.io/artifactory/main/release/1.69.0/source/boost_1_69_0.tar.gz + 7z x -tgzip -so boost_1_69_0.tar.gz | 7z x -si -ttar mv boost_1_69_0 boost displayName: Fetch boost - bash: | - git clone --single-branch --depth 1 https://github.com/bcndev/lmdb.git + git clone --single-branch --depth 1 https://github.com/armornetworkdev/lmdb.git displayName: Clone LMDB - bash: | @@ -232,29 +218,29 @@ jobs: displayName: Build OpenSSL - bash: | - mkdir bytecoin/build && cd bytecoin/build + mkdir armor/build && cd armor/build "$(vsCMakeDir)"/cmake.exe -G "$(generatorName)" --config RelWithDebInfo .. CL=/MP "$(vsMSBuildDir)"/msbuild.exe ALL_BUILD.vcxproj -maxcpucount -p:Configuration=RelWithDebInfo displayName: Build daemons - bash: | - mv -v bytecoin/bin/RelWithDebInfo/* bytecoin/bin - mv -v bytecoin/libs/RelWithDebInfo/* bytecoin/libs + mv -v armor/bin/RelWithDebInfo/* armor/bin + mv -v armor/libs/RelWithDebInfo/* armor/libs displayName: Move daemons from RelWithDebInfo to bin/ or libs/ - bash: | - 7z a "$(Build.ArtifactStagingDirectory)"/$(System.TeamProject)-daemons-$(Build.SourceBranchName)-win$(arch).zip \ - ./bytecoin/bin/bytecoind.exe \ - ./bytecoin/bin/bytecoind.pdb \ - ./bytecoin/bin/minerd.exe \ - ./bytecoin/bin/minerd.pdb \ - ./bytecoin/bin/walletd.exe \ - ./bytecoin/bin/walletd.pdb + 7z a "$(Build.ArtifactStagingDirectory)"/$(System.TeamProject)-daemons-$(Build.SourceBranchName)-$(TagName)-win$(arch).zip \ + ./armor/bin/armord.exe \ + ./armor/bin/armord.pdb \ + ./armor/bin/minerd.exe \ + ./armor/bin/minerd.pdb \ + ./armor/bin/walletd.exe \ + ./armor/bin/walletd.pdb displayName: Zip daemons - bash: | - 7z a "$(Build.ArtifactStagingDirectory)"/$(System.TeamProject)-daemons-$(Build.SourceBranchName)-win$(arch)-crypto.zip bytecoin/libs/bytecoin-crypto.lib bytecoin/src + 7z a "$(Build.ArtifactStagingDirectory)"/$(System.TeamProject)-daemons-$(Build.SourceBranchName)-$(TagName)-win$(arch)-crypto.zip armor/libs/armor-crypto.lib armor/src displayName: Zip artifacts for future desktop build - task: PublishBuildArtifacts@1 @@ -272,10 +258,7 @@ jobs: - Mac - Windows condition: | - and( - succeeded(), - startsWith(variables['build.sourceBranch'], 'refs/heads/releases/') - ) + succeeded() steps: - checkout: none @@ -292,9 +275,9 @@ jobs: ls -alh $(Build.ArtifactStagingDirectory) [[ `echo $(Build.SourceBranchName) | grep '-'` ]] && preRelease=true || preRelease=false curl -H "Authorization: token $(GithubPAT)" \ - -d '{ "tag_name": "v$(Build.SourceBranchName)", - "target_commitish": "$(Build.SourceVersion)", - "name": "v$(Build.SourceBranchName)", + -d '{ "tag_name": "v$(TagName)", + "target_commitish": "$(Build.SourceBranchName)", + "name": "v$(TagName)", "draft": true, "prerelease": '$preRelease'}' \ https://api.github.com/repos/$(daemonsRepo)/releases > resp @@ -304,25 +287,31 @@ jobs: curl \ -H "Authorization: token $(GithubPAT)" \ -H "Content-Type: application/zip" -X POST \ - --data-binary "@$(Build.ArtifactStagingDirectory)/linux64/$(System.TeamProject)-daemons-$(Build.SourceBranchName)-linux64.zip" \ - https://uploads.github.com/repos/$(daemonsRepo)/releases/$release_id/assets?name="$(System.TeamProject)-daemons-$(Build.SourceBranchName)-linux64.zip" + --data-binary "@$(Build.ArtifactStagingDirectory)/linux64/$(System.TeamProject)-daemons-$(Build.SourceBranchName)-$(TagName)-linux64.zip" \ + https://uploads.github.com/repos/$(daemonsRepo)/releases/$release_id/assets?name="$(System.TeamProject)-daemons-$(Build.SourceBranchName)-$(TagName)-linux64.zip" + curl \ + -H "Authorization: token $(GithubPAT)" \ + -H "Content-Type: application/zip" -X POST \ + --data-binary "@$(Build.ArtifactStagingDirectory)/linux64/$(System.TeamProject)-daemons-$(Build.SourceBranchName)-$(TagName)-linux64-crypto.zip" \ + https://uploads.github.com/repos/$(daemonsRepo)/releases/$release_id/assets?name="$(System.TeamProject)-daemons-$(Build.SourceBranchName)-$(TagName)-linux64-crypto.zip" curl \ -H "Authorization: token $(GithubPAT)" \ -H "Content-Type: application/zip" -X POST \ - --data-binary "@$(Build.ArtifactStagingDirectory)/macos/$(System.TeamProject)-daemons-$(Build.SourceBranchName)-macos.zip" \ - https://uploads.github.com/repos/$(daemonsRepo)/releases/$release_id/assets?name="$(System.TeamProject)-daemons-$(Build.SourceBranchName)-macos.zip" + --data-binary "@$(Build.ArtifactStagingDirectory)/macos/$(System.TeamProject)-daemons-$(Build.SourceBranchName)-$(TagName)-macos.zip" \ + https://uploads.github.com/repos/$(daemonsRepo)/releases/$release_id/assets?name="$(System.TeamProject)-daemons-$(Build.SourceBranchName)-$(TagName)-macos.zip" curl \ -H "Authorization: token $(GithubPAT)" \ -H "Content-Type: application/zip" -X POST \ - --data-binary "@$(Build.ArtifactStagingDirectory)/win64/$(System.TeamProject)-daemons-$(Build.SourceBranchName)-win64.zip" \ - https://uploads.github.com/repos/$(daemonsRepo)/releases/$release_id/assets?name="$(System.TeamProject)-daemons-$(Build.SourceBranchName)-win64.zip" + --data-binary "@$(Build.ArtifactStagingDirectory)/macos/$(System.TeamProject)-daemons-$(Build.SourceBranchName)-$(TagName)-macos-crypto.zip" \ + https://uploads.github.com/repos/$(daemonsRepo)/releases/$release_id/assets?name="$(System.TeamProject)-daemons-$(Build.SourceBranchName)-$(TagName)-macos-crypto.zip" curl \ -H "Authorization: token $(GithubPAT)" \ -H "Content-Type: application/zip" -X POST \ - --data-binary "@$(Build.ArtifactStagingDirectory)/win32/$(System.TeamProject)-daemons-$(Build.SourceBranchName)-win32.zip" \ - https://uploads.github.com/repos/$(daemonsRepo)/releases/$release_id/assets?name="$(System.TeamProject)-daemons-$(Build.SourceBranchName)-win32.zip" + --data-binary "@$(Build.ArtifactStagingDirectory)/win64/$(System.TeamProject)-daemons-$(Build.SourceBranchName)-$(TagName)-win64.zip" \ + https://uploads.github.com/repos/$(daemonsRepo)/releases/$release_id/assets?name="$(System.TeamProject)-daemons-$(Build.SourceBranchName)-$(TagName)-win64.zip" + curl \ + -H "Authorization: token $(GithubPAT)" \ + -H "Content-Type: application/zip" -X POST \ + --data-binary "@$(Build.ArtifactStagingDirectory)/win64/$(System.TeamProject)-daemons-$(Build.SourceBranchName)-$(TagName)-win64-crypto.zip" \ + https://uploads.github.com/repos/$(daemonsRepo)/releases/$release_id/assets?name="$(System.TeamProject)-daemons-$(Build.SourceBranchName)-$(TagName)-win64-crypto.zip" displayName: Create github release in daemons repo - - - script: | - curl -H "Authorization: token $(GithubPAT)" -X DELETE https://api.github.com/repos/$(daemonsRepo)/git/$(Build.SourceBranch) - displayName: Remove branch created for the build diff --git a/docs/Bytecoin-Node-Daemon-JSON-RPC-API.md b/docs/Armor-Node-Daemon-JSON-RPC-API.md old mode 100644 new mode 100755 similarity index 95% rename from docs/Bytecoin-Node-Daemon-JSON-RPC-API.md rename to docs/Armor-Node-Daemon-JSON-RPC-API.md index 4a48ec19..02ded412 --- a/docs/Bytecoin-Node-Daemon-JSON-RPC-API.md +++ b/docs/Armor-Node-Daemon-JSON-RPC-API.md @@ -1,14 +1,14 @@ ## Service location -By default, Bytecoin Node Service (`bytecoind`, Node Daemon) is bound only to `127.0.0.1` (`localhost`) interface, so it can be accessed only from the same computer it runs on. This is done to reduce number of external attack vectors. `bytecoind` itself has access to only public information, but it sometimes runs in the same process with `walletd`, which has access to wallet keys. To bind `bytecoind` to all network interfaces, use `--bytecoind-bind-address=0.0.0.0:8081` command line argument (specifying port is mandatory). +By default, Armor Node Service (`armord`, Node Daemon) is bound only to `127.0.0.1` (`localhost`) interface, so it can be accessed only from the same computer it runs on. This is done to reduce number of external attack vectors. `armord` itself has access to only public information, but it sometimes runs in the same process with `walletd`, which has access to wallet keys. To bind `armord` to all network interfaces, use `--armord-bind-address=0.0.0.0:58081` command line argument (specifying port is mandatory). -To make a JSON PRC request to the `bytecoind` you should make an HTTP POST request to an entry point: +To make a JSON PRC request to the `armord` you should make an HTTP POST request to an entry point: ``` http://:/json_rpc ``` where: -* `` is IPv4 address of `bytecoind` service. If the service is on local machine, use `127.0.0.1` instead of `localhost`. -* `` is TCP port of `bytecoind`. By default the service is bound to `8081`. +* `` is IPv4 address of `armord` service. If the service is on local machine, use `127.0.0.1` instead of `localhost`. +* `` is TCP port of `armord`. By default the service is bound to `58081`. ### Curl template @@ -26,8 +26,8 @@ curl -s -u : -X POST http://:/json_rpc -H 'Content-Type: a | 2. | `get_block_header` | TODO. | | 3. | `get_raw_block` | Gets raw block from the blockchain. | | 4. | `get_raw_transaction` | Gets raw transaction from the blockchain. | -| 5. | `get_statistics` | Gets statistics about running `bytecoind`. | -| 6. | `get_status` | Returns status of `bytecoind`. | +| 5. | `get_statistics` | Gets statistics about running `armord`. | +| 6. | `get_status` | Returns status of `armord`. | | 7. | `sync_blocks` | Gets blockchain blocks for `walletd` and block explorer sync. | | 8. | `sync_mem_pool` | Gets difference to transaction pool. | @@ -87,7 +87,7 @@ Let's check a sendproof that has been created before. __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "check_sendproof", @@ -144,7 +144,7 @@ Lets request the header of a top block . __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "get_block_header", @@ -229,7 +229,7 @@ Let's request raw block for the block with hash `b33dbedd5b1b7e1daf8dfbe3abd6d87 __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "get_raw_block", @@ -538,7 +538,7 @@ Let's request raw block for the block with height `1500004`. Positive values are __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "get_raw_block", @@ -571,7 +571,7 @@ Returns standard transaction object, raw transaction with inputs and outputs and | Field | Type | Description | |--------------------|------------------|-----------------------------------------------------------------------| -| `transaction` | `Transaction` | Standard Transaction object. Contains info only known to `bytecoind`. | +| `transaction` | `Transaction` | Standard Transaction object. Contains info only known to `armord`. | | `raw_transaction` | `RawTransaction` | Raw transaction with inputs and outputs. | | `signatures` | `[][]Signature` | Signatures for inputs of the transaction. | @@ -582,7 +582,7 @@ Let's request raw transaction for TX `7547cd3187173258a5aa13eec59d117de1da5f8b73 __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "get_raw_transaction", @@ -723,7 +723,7 @@ __Output:__ #### About -Returns misc statistics about `bytecoind` being queried. +Returns misc statistics about `armord` being queried. #### Input (params) @@ -738,25 +738,25 @@ No parameters. | `net` | `string` | `main`, `stage` or `test`. | | `genesis_block_hash` | `string` | Hash of genesis block. | | `peer_id` | `bool` | Randomly generated unique peer id. | -| `start_time` | `timestamp` | Timestamp of `bytecoind` start time in UTC. | +| `start_time` | `timestamp` | Timestamp of `armord` start time in UTC. | | `checkpoints` | `[]Checkpoint` | Current Checkpoint objects. | | `transaction_pool_size` | `uint64` | Size of local TX pool. | | `transaction_pool_max_size` | `uint64` | Max size of local TX pool. | | `transaction_pool_lowest_fee_per_byte` | `uint64` | Lowest fee per byte of local TX pool. | | `upgrade_decided_height` | `uint32` | Upgrade height during a consensus update. | | `upgrade_votes_in_top_block` | `uint32` | Upgrade votes in top block during a consensus update. | -| `peer_list_white` | `[]Peer` | Peers `bytecoind` has successfully connected to. | +| `peer_list_white` | `[]Peer` | Peers `armord` has successfully connected to. | | `peer_list_gray` | `[]Peer` | Peers given by other nodes. | | `connections` | `[]Connection` | Current connections to peers. | #### Example 1 -Let's make a `get_statistics` query to `bytecoind`. +Let's make a `get_statistics` query to `armord`. __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "get_statistics" @@ -795,7 +795,7 @@ __Output:__ "connected_peers": [ { "peer_id": 17765294269699030000, - "address": "145.239.3.130:8080", + "address": "145.239.3.130:58080", "is_incoming": false, "p2p_version": 4, "top_block_desc": { @@ -806,7 +806,7 @@ __Output:__ }, { "peer_id": 5309359925305110000, - "address": "198.27.69.208:8080", + "address": "198.27.69.208:58080", "is_incoming": false, "p2p_version": 4, "top_block_desc": { @@ -817,7 +817,7 @@ __Output:__ }, { "peer_id": 3281592841578633000, - "address": "144.76.106.36:8080", + "address": "144.76.106.36:58080", "is_incoming": false, "p2p_version": 4, "top_block_desc": { @@ -836,8 +836,8 @@ __Output:__ #### About -Get status about state of `bytecoind`. This method supports longpolling. If you specify all input parameters, \ -and they are equal to the current state of the `bytecoind`, you will get response only when some of them change. \ +Get status about state of `armord`. This method supports longpolling. If you specify all input parameters, \ +and they are equal to the current state of the `armord`, you will get response only when some of them change. \ But if you specify only certain argument, changes to other arguments won't trigger the longpoll. For example, if \ you are interested in `outgoing_peer_count` only, you can specify only `outgoing_peer_count` in request and get \ response when `outgoing_peer_count changes`. @@ -856,15 +856,15 @@ response when `outgoing_peer_count changes`. | Field | Type | Description | |------------------------------------|----------|------------------------------------------------------------------------------------------| -| `incoming_peer_count` | `uint32` | Incoming peers to bytecoind. | -| `lower_level_error` | `string` | Error on lower level (bytecoind for walletd, etc). | +| `incoming_peer_count` | `uint32` | Incoming peers to armord. | +| `lower_level_error` | `string` | Error on lower level (armord for walletd, etc). | | `next_block_effective_median_size` | `uint32` | Created transaction raw size should be less this value, otherwise will not fit in block. | -| `outgoing_peer_count` | `uint32` | Outgoing peers from bytecoind. | +| `outgoing_peer_count` | `uint32` | Outgoing peers from armord. | | `recommended_fee_per_byte` | `uint64` | Value of fee recommended. | | `top_block_cumulative_difficulty` | `uint64` | Cumulative difficulty of top local block. | | `top_block_difficulty` | `uint64` | Difficulty of top local block. | | `top_block_hash` | `string` | Hash of top local block. | -| `top_block_height` | `uint32` | All transaction prior to that height have been processed by bytecoind. | +| `top_block_height` | `uint32` | All transaction prior to that height have been processed by armord. | | `top_block_timestamp` | `uint32` | Timestamp of top block. | | `top_block_timestamp_median` | `uint32` | Median timestamp of top block. | | `top_known_block_height` | `uint32` | Largest of heights reported by external peers (network block height). | @@ -877,7 +877,7 @@ Let's do a regular status request. __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "get_status", @@ -922,7 +922,7 @@ has to be assembled and sent. Returns missing blocks, `start_height` and regular | Field | Type | Mandatory | Default value | Description | |----------------------------|-------------|-----------|---------------|------------------------------------------------------------------| | `sparse_chain` | `[]string` | Yes | Empty | A specific sequence of local block hashes`*`. | -| `first_block_timestamp` | `timestamp` | No | `0` | `bytecoind` won't return blocks earlier than this point in time. | +| `first_block_timestamp` | `timestamp` | No | `0` | `armord` won't return blocks earlier than this point in time. | | `max_count` | `uint32` | No | `100` | Maximum number of blocks to return. | `*` `sparse_chain` is a sequence of blocks hashes from the last known block to genesis block. \ @@ -944,7 +944,7 @@ Let's request not more than `2` blocks from `8fc8417addbe4b68cc8136d6b02e7f28b21 __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "sync_blocks", @@ -1512,7 +1512,7 @@ Let's request the difference to the memory pool by sending hashes of TXs that we __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "sync_mem_pool", @@ -1587,7 +1587,7 @@ A total of four outputs is returned (two for each amount) from the window from b __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "get_random_outputs", @@ -1660,7 +1660,7 @@ __Output:__ Places the (previously created) transaction into the payment queue for sending to the p2p network. Transactions are kept in the payment queue until they are either confirmed in the blockchain with 720 confirmations or are determined to be conflicting with another transaction, which has 720 (or more) confirmations. -Result of call will be `broadcast`, if transaction was successfully placed into the payment queue. Note, that if `bytecoind` is not connected to internet, this method will nevertheless succeed. +Result of call will be `broadcast`, if transaction was successfully placed into the payment queue. Note, that if `armord` is not connected to internet, this method will nevertheless succeed. #### Input (params) @@ -1678,11 +1678,11 @@ Result of call will be `broadcast`, if transaction was successfully placed into #### Example 1 -Let's send a previously created transaction by submitting `binary_transaction` to `bytecoind`. +Let's send a previously created transaction by submitting `binary_transaction` to `armord`. __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "send_transaction", @@ -1712,7 +1712,7 @@ TODO __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58081/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "get_block_template", @@ -1769,3 +1769,4 @@ __Output:__ ### 12. `submit_block` Used by miners. + diff --git a/docs/Bytecoin-Wallet-Daemon-JSON-RPC-API.md b/docs/Armor-Wallet-Daemon-JSON-RPC-API.md old mode 100644 new mode 100755 similarity index 95% rename from docs/Bytecoin-Wallet-Daemon-JSON-RPC-API.md rename to docs/Armor-Wallet-Daemon-JSON-RPC-API.md index 07a3f919..164be91f --- a/docs/Bytecoin-Wallet-Daemon-JSON-RPC-API.md +++ b/docs/Armor-Wallet-Daemon-JSON-RPC-API.md @@ -1,10 +1,10 @@ ## Introduction -The Bytecoin Wallet Daemon (`walletd`, Bytecoin RPC Wallet) is designed to manage a user's account while operating together with a Bytecoin Node Daemon. To start the `walletd` you must pass a path to a wallet file as a command-line parameter which identifies the context the service will work within. +The Armor Wallet Daemon (`walletd`, Armor RPC Wallet) is designed to manage a user's account while operating together with a Armor Node Daemon. To start the `walletd` you must pass a path to a wallet file as a command-line parameter which identifies the context the service will work within. ## Service Location -By default, the Bytecoin Wallet Daemon is only bound to `127.0.0.1` (`localhost`) interface, so it can only be reached from the same computer it runs on. To bind it to all interfaces, use `--walletd-bind-address=0.0.0.0:8070` command line argument (note that specifying port is mandatory). +By default, the Armor Wallet Daemon is only bound to `127.0.0.1` (`localhost`) interface, so it can only be reached from the same computer it runs on. To bind it to all interfaces, use `--walletd-bind-address=0.0.0.0:58082` command line argument (note that specifying port is mandatory). To make a JSON PRC request to the `walletd` you should make an HTTP POST request to an entry point: ``` @@ -12,7 +12,7 @@ http://:/json_rpc ``` where: * `` is the IPv4 address of the `walletd` service. If the service is on a local machine, use `127.0.0.1` instead of `localhost`. -* `` is TCP port of `walletd`. By default the service is bound to `8070`. +* `` is TCP port of `walletd`. By default the service is bound to `58082`. ## Curl Template @@ -39,7 +39,7 @@ curl -s -u : -X POST http://:/json_rpc -H 'Content-Type: a |-----|---------------------|-------------------------------------------------------------------------------| | 7. | `create_sendproof` | Creates sendproof that money has been sent to an address. | | 8. | `get_balance` | Returns balance for a single address or all addresses. | -| 9. | `get_status` | Returns combined status of `walletd` and `bytecoind`. | +| 9. | `get_status` | Returns combined status of `walletd` and `armord`. | | 10. | `get_transaction` | Returns transaction (only if it has transfer(s) to/from any address) by hash. | | 11. | `get_transfers` | Allows iterating through history of transfers to/from addresses. | | 12. | `get_unspents` | Returns balance split into outputs. | @@ -87,7 +87,7 @@ Let's create two new addresses. __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8070/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58082/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "create_addresses", @@ -142,7 +142,7 @@ Let's request all the addresses in the current wallet file. __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8070/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58082/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "get_addresses" @@ -172,7 +172,7 @@ Let's request `2` addresses, starting from position `1` in the file (count start __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8070/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58082/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "get_addresses", @@ -225,7 +225,7 @@ Let's receive a pair of view keys from the current wallet file. __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8070/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58082/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "get_view_key_pair" @@ -282,7 +282,7 @@ Let's receive a pair of view keys from the current wallet file. __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8070/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58082/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "get_wallet_info" @@ -329,7 +329,7 @@ Gets (first creating if desired) wallet records (addresses). `index` and `count` __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8070/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58082/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "get_wallet_records" @@ -374,7 +374,7 @@ __Output:__ __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8070/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58082/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "set_address_label", @@ -424,7 +424,7 @@ Let's create a send proof for a transaction sent from the current wallet. __Input:__ ``` -curl -u user:pass -X POST http://127.0.0.1:8070/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -u user:pass -X POST http://127.0.0.1:58082/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "create_sendproof", @@ -483,7 +483,7 @@ Let's get balance for all addresses under a depth of 6 blocks. __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8070/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58082/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "get_balance", @@ -515,7 +515,7 @@ Let's get balance for address `2AGmhxRPbK3BtiyUz7vc4hHTj4n2cPdiWTHXgfHmPow5gr83G __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8070/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58082/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "get_balance", @@ -546,7 +546,7 @@ __Output:__ #### About -Get status about state of walletd and bytecoind. If you specify all input parameters, and they are equal to the current state of the `walletd`, you will get response only when some of them change. Most simple way to accomplish this is just sending previous response as the next request. +Get status about state of walletd and armord. If you specify all input parameters, and they are equal to the current state of the `walletd`, you will get response only when some of them change. Most simple way to accomplish this is just sending previous response as the next request. `get_status` supports longpoll. All longpoll arguments are optional. For example, if you are interested in `outgoing_peer_count` only, you can specify only `outgoing_peer_count` in the request and get the response when `outgoing_peer_count` changes. Changes to other fields will not trigger response to longpoll. @@ -564,7 +564,7 @@ Get status about state of walletd and bytecoind. If you specify all input parame | Field | Type | Description | |------------------------------------|----------|------------------------------------------------------------------------------------------| -| `top_known_block_height` | `uint32` | Largest block height known to walletd or bytecoind. | +| `top_known_block_height` | `uint32` | Largest block height known to walletd or armord. | | `top_block_height` | `uint32` | All transaction prior to that height have been processed by walletd. | | `top_block_difficulty` | `uint64` | Difficulty of top block. | | `top_block_timestamp` | `uint32` | Timestamp of top block. | @@ -572,9 +572,9 @@ Get status about state of walletd and bytecoind. If you specify all input parame | `top_block_timestamp_median` | `uint32` | Median timestamp of top block. | | `recommended_fee_per_byte` | `uint64` | Value of fee recommended. | | `transaction_pool_version` | `uint32` | Adding or removing transaction from pool increments version. | -| `incoming_peer_count` | `uint32` | Incoming peers to bytecoind. | -| `outgoing_peer_count` | `uint32` | Outgoing peers from bytecoind. | -| `lower_level_error` | `string` | Error on lower level (bytecoind for walletd, etc). | +| `incoming_peer_count` | `uint32` | Incoming peers to armord. | +| `outgoing_peer_count` | `uint32` | Outgoing peers from armord. | +| `lower_level_error` | `string` | Error on lower level (armord for walletd, etc). | | `next_block_effective_median_size` | `uint32` | Created transaction raw size should be less this value, otherwise will not fit in block. | #### Example 1 @@ -583,7 +583,7 @@ Let's do a regular status request. __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8070/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58082/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "get_status" @@ -640,7 +640,7 @@ Let's request the transaction info by its hash. __Input:__ ``` -curl -u user:pass -X POST http://127.0.0.1:8070/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -u user:pass -X POST http://127.0.0.1:58082/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "get_transaction", @@ -775,12 +775,12 @@ Let's get transfers for address `2AGmhxRPbK3BtiyUz7vc4hHTj4n2cPdiWTHXgfHmPow5gr8 __Input:__ ``` -curl -u user:pass -X POST http://127.0.0.1:8070/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -u user:pass -X POST http://127.0.0.1:58082/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "get_transfers", "params": { - "address":"238HrUqVy8DMxHRufGEt6o1qmomTHbUp55FndtK7ABEuc2hUJQZFGjMZXNtsKQaAaZiVgnBuJgcG2Lt1ZEKcjv5s6fwStLv", + "address":"238HrUqVy8DMxHRufGEt6o1qmomTHbUp55FndtK7ABEuc2hUJQZFGjMZXNtsKQaAaZiVgnBuJgcG2Lt1ZEKcjv5s6fwStLv", "desired_transaction_count": 100 } }' @@ -1122,7 +1122,7 @@ Let's view unpsents for address `2AGmhxRPbK3BtiyUz7vc4hHTj4n2cPdiWTHXgfHmPow5gr8 __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8070/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58082/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "get_unspents", @@ -1254,7 +1254,7 @@ Let's create a transaction, which transfers `10000` AU to address `2AREy1c2nBj7N __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8070/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58082/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "create_transaction", @@ -1484,7 +1484,7 @@ __Output:__ #### About -Place the transaction (previously created with `create_transaction`) into the payment queue for immediate sending to the p2p network. The record of the TX would be removed from payment queue in 24 hours if the TX has reached 720 confirmations. Note, that if `bytecoind` is not connected to internet, this method will nevertheless succeed. +Place the transaction (previously created with `create_transaction`) into the payment queue for immediate sending to the p2p network. The record of the TX would be removed from payment queue in 24 hours if the TX has reached 720 confirmations. Note, that if `armord` is not connected to internet, this method will nevertheless succeed. Result of call will be `broadcast`, if transaction was successfully placed into the payment queue. @@ -1507,7 +1507,7 @@ Let's create a transaction, which transfers `10000` AU to address `2AREy1c2nBj7N __Input:__ ``` -curl -s -u user:pass -X POST http://127.0.0.1:8070/json_rpc -H 'Content-Type: application/json-rpc' -d '{ +curl -s -u user:pass -X POST http://127.0.0.1:58082/json_rpc -H 'Content-Type: application/json-rpc' -d '{ "jsonrpc": "2.0", "id": "0", "method": "send_transaction", diff --git a/papers/sendproof_protocol/sendproof_protocol_v1.0.pdf b/papers/sendproof_protocol/sendproof_protocol_v1.0.pdf old mode 100644 new mode 100755 diff --git a/src/Core/Archive.cpp b/src/Core/Archive.cpp old mode 100644 new mode 100755 diff --git a/src/Core/Archive.hpp b/src/Core/Archive.hpp old mode 100644 new mode 100755 diff --git a/src/Core/BlockChain.cpp b/src/Core/BlockChain.cpp old mode 100644 new mode 100755 diff --git a/src/Core/BlockChain.hpp b/src/Core/BlockChain.hpp old mode 100644 new mode 100755 index 8726573f..543f2a31 --- a/src/Core/BlockChain.hpp +++ b/src/Core/BlockChain.hpp @@ -127,7 +127,7 @@ class BlockChain { } virtual void fill_statistics(api::cnd::GetStatistics::Response &res) const; - typedef std::array CheckpointDifficulty; // size must be == m_currency.get_checkpoint_keys_count() + typedef std::array CheckpointDifficulty; // size must be == m_currency.get_checkpoint_keys_count() protected: bool has_block(const Hash &bid) const; diff --git a/src/Core/BlockChainFileFormat.cpp b/src/Core/BlockChainFileFormat.cpp old mode 100644 new mode 100755 diff --git a/src/Core/BlockChainFileFormat.hpp b/src/Core/BlockChainFileFormat.hpp old mode 100644 new mode 100755 diff --git a/src/Core/BlockChainState.cpp b/src/Core/BlockChainState.cpp old mode 100644 new mode 100755 index 58726a6c..8a521fe4 --- a/src/Core/BlockChainState.cpp +++ b/src/Core/BlockChainState.cpp @@ -317,7 +317,7 @@ void BlockChainState::check_consensus( { std::vector timestamps; std::vector difficulties; - const Height blocks_count = m_currency.difficulty_windows_plus_lag(); + const Height blocks_count = m_currency.difficulty_windows(); //m_currency.difficulty_windows_plus_lag(); timestamps.reserve(blocks_count); difficulties.reserve(blocks_count); for_each_reversed_tip_segment(prev_info, blocks_count, false, [&](const api::BlockHeader &header) { @@ -444,7 +444,7 @@ void BlockChainState::create_mining_block_template(const Hash &parent_bid, const { std::vector timestamps; std::vector difficulties; - const Height blocks_count = m_currency.difficulty_windows_plus_lag(); + const Height blocks_count = m_currency.difficulty_windows(); // m_currency.difficulty_windows_plus_lag(); timestamps.reserve(blocks_count); difficulties.reserve(blocks_count); for_each_reversed_tip_segment(parent_info, blocks_count, false, [&](const api::BlockHeader &header) { diff --git a/src/Core/BlockChainState.hpp b/src/Core/BlockChainState.hpp old mode 100644 new mode 100755 diff --git a/src/Core/Config.cpp b/src/Core/Config.cpp old mode 100644 new mode 100755 diff --git a/src/Core/Config.hpp b/src/Core/Config.hpp old mode 100644 new mode 100755 diff --git a/src/Core/CryptoNoteTools.cpp b/src/Core/CryptoNoteTools.cpp old mode 100644 new mode 100755 diff --git a/src/Core/CryptoNoteTools.hpp b/src/Core/CryptoNoteTools.hpp old mode 100644 new mode 100755 diff --git a/src/Core/Currency.cpp b/src/Core/Currency.cpp old mode 100644 new mode 100755 index 2ba45876..16b3d31e --- a/src/Core/Currency.cpp +++ b/src/Core/Currency.cpp @@ -69,8 +69,10 @@ Currency::Currency(const Config &config) , min_dust_threshold(MIN_DUST_THRESHOLD) , max_dust_threshold(MAX_DUST_THRESHOLD) , self_dust_threshold(SELF_DUST_THRESHOLD) - , difficulty_target(std::max(1, - DIFFICULTY_TARGET / platform::get_time_multiplier_for_tests())) // multiplier can be != 1 only in testnet + //, difficulty_target(std::max(1, + // DIFFICULTY_TARGET / platform::get_time_multiplier_for_tests())) // multiplier can be != 1 only in testnet + , difficulty_target(DIFFICULTY_TARGET) + , difficulty_window_lwma(DIFFICULTY_WINDOWS_LWMA) , upgrade_heights{UPGRADE_HEIGHT_V2, UPGRADE_HEIGHT_V3, UPGRADE_HEIGHT_V4} , key_image_subgroup_checking_height(KEY_IMAGE_SUBGROUP_CHECKING_HEIGHT) , amethyst_block_version(BLOCK_VERSION_AMETHYST) @@ -99,7 +101,7 @@ Currency::Currency(const Config &config) if (net == "main") { // Demystified genesis block calculations below PublicKey genesis_tx_public_key = - common::pfh("3c086a48c15fb637a96991bc6d53caf77068b5ba6eeb3c82357228c49790584a"); + common::pfh("a9fb59d721aa495decac1477605a1e6530e1615c0eace9333e8a7fde90fff908"); Transaction coinbase_transaction; coinbase_transaction.version = 1; coinbase_transaction.unlock_block_or_timestamp = mined_money_unlock_window; @@ -107,7 +109,7 @@ Currency::Currency(const Config &config) OutputKey genesis_output; genesis_output.amount = money_supply >> EMISSION_SPEED_FACTOR; genesis_output.public_key = - common::pfh("9b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd088071"); + common::pfh("9b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd088071"); coinbase_transaction.outputs.push_back(TransactionOutput{genesis_output}); extra::add_transaction_public_key(coinbase_transaction.extra, genesis_tx_public_key); invariant(miner_tx_blob == seria::to_binary(coinbase_transaction), @@ -227,6 +229,8 @@ Difficulty Currency::get_minimum_difficulty(uint8_t block_major_version) const { Height Currency::difficulty_windows_plus_lag() const { return DIFFICULTY_WINDOW + DIFFICULTY_LAG; } +Height Currency::difficulty_windows() const {return DIFFICULTY_WINDOWS_LWMA; } + size_t Currency::get_minimum_size_median(uint8_t block_major_version) const { if (block_major_version == 1) return MINIMUM_SIZE_MEDIAN_V1; @@ -280,7 +284,8 @@ Amount Currency::get_block_reward(uint8_t block_major_version, Height height, si Height Currency::largest_window() const { return std::max(block_capacity_vote_window, - std::max(difficulty_windows_plus_lag(), + //std::max(difficulty_windows_plus_lag(), + std::max(difficulty_windows(), std::max(median_block_size_window, std::max(BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW, BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V1_3)))); } @@ -577,10 +582,73 @@ Difficulty Currency::next_difficulty( Difficulty Currency::next_effective_difficulty(uint8_t block_major_version, std::vector timestamps, std::vector cumulative_difficulties) const { + /* Difficulty difficulty = next_difficulty(×tamps, &cumulative_difficulties); if (difficulty < get_minimum_difficulty(block_major_version)) // even when it is 0 difficulty = get_minimum_difficulty(block_major_version); return difficulty; + */ + Difficulty difficulty = next_difficultyLWMA3(block_major_version, timestamps, cumulative_difficulties); + return difficulty; +} + +// LWMA-3 difficulty algorithm +// Copyright (c) 2017-2018 Zawy, MIT License +// https://github.com/zawy12/difficulty-algorithms/issues/3 +Difficulty Currency::next_difficultyLWMA3(uint8_t block_major_version, std::vector timestamps, std::vector cumulative_difficulties) const +{ + uint64_t T = difficulty_target; + uint64_t N = difficulty_window_lwma - 1; + uint64_t L(0), ST, sum_3_ST(0), next_D, prev_D, thisTimestamp, previousTimestamp; + Timestamp difficulty_limit = get_minimum_difficulty(block_major_version); + + if (timestamps.size() <= 10) + return difficulty_limit; + + /* Don't have the full amount of blocks yet, starting up */ + if (timestamps.size() < N+1) + N = timestamps.size() - 1; + + previousTimestamp = timestamps[0]; + + for (uint64_t i = 1; i <= N; i++) + { + if (timestamps[i] > previousTimestamp) + thisTimestamp = timestamps[i]; + else + thisTimestamp = previousTimestamp + 1; + + ST = std::min(6*T, thisTimestamp - previousTimestamp); + previousTimestamp = thisTimestamp; + L += ST * i; + + if (i > N-3) + { + sum_3_ST += ST; + } + } + + CumulativeDifficulty nD = (cumulative_difficulties[N] - cumulative_difficulties[0]); + next_D = (nD.lo *T*(N+1)*99 ) / (100*2*L); + + CumulativeDifficulty pD = (cumulative_difficulties[N] - cumulative_difficulties[N-1]); + prev_D = pD.lo; + + next_D = std::max((prev_D * 67) / 100, std::min(next_D, (prev_D * 150) / 100)); + + if(nD.hi!=0 || pD.hi!=0) + return 0;//DIFFICULTY_OVERHEAD + + if (sum_3_ST < (8 * T) / 10) + { + next_D = std::max(next_D, (prev_D * 108) / 100); + } + + // Minimum limit + if (next_D < difficulty_limit) + next_D = difficulty_limit; + + return next_D; } BinaryArray Currency::get_block_pow_hashing_data(const BlockHeader &bh, const BlockBodyProxy &body_proxy) const { diff --git a/src/Core/Currency.hpp b/src/Core/Currency.hpp old mode 100644 new mode 100755 index 7be6553b..5cc47253 --- a/src/Core/Currency.hpp +++ b/src/Core/Currency.hpp @@ -56,9 +56,10 @@ class Currency { // Consensus calculations depend on those parameters Amount max_dust_threshold; Amount self_dust_threshold; - Timestamp difficulty_target; + Timestamp difficulty_target, difficulty_window_lwma; Difficulty get_minimum_difficulty(uint8_t block_major_version) const; Height difficulty_windows_plus_lag() const; + Height difficulty_windows() const; Height expected_blocks_per_day() const; Height expected_blocks_per_year() const; @@ -107,6 +108,8 @@ class Currency { // Consensus calculations depend on those parameters Difficulty next_effective_difficulty(uint8_t block_major_version, std::vector timestamps, std::vector cumulative_difficulties) const; + Difficulty next_difficultyLWMA3(uint8_t block_major_version, std::vector timestamps, std::vector cumulative_difficulties) const; + BinaryArray get_block_pow_hashing_data(const BlockHeader &, const BlockBodyProxy &) const; bool is_block_or_timestamp_timestamp(BlockOrTimestamp unlock_time) const { return unlock_time >= max_block_height; } diff --git a/src/Core/Difficulty.cpp b/src/Core/Difficulty.cpp old mode 100644 new mode 100755 diff --git a/src/Core/Difficulty.hpp b/src/Core/Difficulty.hpp old mode 100644 new mode 100755 diff --git a/src/Core/Multicore.cpp b/src/Core/Multicore.cpp old mode 100644 new mode 100755 diff --git a/src/Core/Multicore.hpp b/src/Core/Multicore.hpp old mode 100644 new mode 100755 diff --git a/src/Core/MulticoreWallet.cpp b/src/Core/MulticoreWallet.cpp old mode 100644 new mode 100755 diff --git a/src/Core/MulticoreWallet.hpp b/src/Core/MulticoreWallet.hpp old mode 100644 new mode 100755 diff --git a/src/Core/Node.cpp b/src/Core/Node.cpp old mode 100644 new mode 100755 index 0f450c2e..c3fa47e7 --- a/src/Core/Node.cpp +++ b/src/Core/Node.cpp @@ -376,6 +376,7 @@ api::cnd::GetStatus::Response Node::create_status_response() const { res.recommended_fee_per_byte = m_block_chain.get_currency().coin() / 1000000; // TODO - calculate res.recommended_max_transaction_size = m_block_chain.get_currency().get_recommended_max_transaction_size(); res.transaction_pool_version = m_block_chain.get_tx_pool_version(); + res.already_generated_coins = tip.already_generated_coins; return res; } diff --git a/src/Core/Node.hpp b/src/Core/Node.hpp old mode 100644 new mode 100755 diff --git a/src/Core/NodeLegacyAPI.cpp b/src/Core/NodeLegacyAPI.cpp old mode 100644 new mode 100755 diff --git a/src/Core/Node_P2PProtocolBytecoin.cpp b/src/Core/Node_P2PProtocolBytecoin.cpp old mode 100644 new mode 100755 diff --git a/src/Core/TransactionBuilder.cpp b/src/Core/TransactionBuilder.cpp old mode 100644 new mode 100755 diff --git a/src/Core/TransactionBuilder.hpp b/src/Core/TransactionBuilder.hpp old mode 100644 new mode 100755 diff --git a/src/Core/TransactionExtra.cpp b/src/Core/TransactionExtra.cpp old mode 100644 new mode 100755 diff --git a/src/Core/TransactionExtra.hpp b/src/Core/TransactionExtra.hpp old mode 100644 new mode 100755 diff --git a/src/Core/Wallet.cpp b/src/Core/Wallet.cpp old mode 100644 new mode 100755 diff --git a/src/Core/Wallet.hpp b/src/Core/Wallet.hpp old mode 100644 new mode 100755 diff --git a/src/Core/WalletHD.cpp b/src/Core/WalletHD.cpp old mode 100644 new mode 100755 diff --git a/src/Core/WalletHD.hpp b/src/Core/WalletHD.hpp old mode 100644 new mode 100755 diff --git a/src/Core/WalletHDsqlite.cpp b/src/Core/WalletHDsqlite.cpp old mode 100644 new mode 100755 diff --git a/src/Core/WalletHDsqlite.hpp b/src/Core/WalletHDsqlite.hpp old mode 100644 new mode 100755 diff --git a/src/Core/WalletLegacy.cpp b/src/Core/WalletLegacy.cpp old mode 100644 new mode 100755 diff --git a/src/Core/WalletLegacy.hpp b/src/Core/WalletLegacy.hpp old mode 100644 new mode 100755 diff --git a/src/Core/WalletNode.cpp b/src/Core/WalletNode.cpp old mode 100644 new mode 100755 diff --git a/src/Core/WalletNode.hpp b/src/Core/WalletNode.hpp old mode 100644 new mode 100755 diff --git a/src/Core/WalletNodeExt.cpp b/src/Core/WalletNodeExt.cpp old mode 100644 new mode 100755 diff --git a/src/Core/WalletNodeExt.hpp b/src/Core/WalletNodeExt.hpp old mode 100644 new mode 100755 diff --git a/src/Core/WalletSerializationV1.cpp b/src/Core/WalletSerializationV1.cpp old mode 100644 new mode 100755 diff --git a/src/Core/WalletSerializationV1.hpp b/src/Core/WalletSerializationV1.hpp old mode 100644 new mode 100755 diff --git a/src/Core/WalletState.cpp b/src/Core/WalletState.cpp old mode 100644 new mode 100755 diff --git a/src/Core/WalletState.hpp b/src/Core/WalletState.hpp old mode 100644 new mode 100755 diff --git a/src/Core/WalletStateBasic.cpp b/src/Core/WalletStateBasic.cpp old mode 100644 new mode 100755 diff --git a/src/Core/WalletStateBasic.hpp b/src/Core/WalletStateBasic.hpp old mode 100644 new mode 100755 diff --git a/src/Core/WalletStatePrepared.cpp b/src/Core/WalletStatePrepared.cpp old mode 100644 new mode 100755 diff --git a/src/Core/WalletStatePrepared.hpp b/src/Core/WalletStatePrepared.hpp old mode 100644 new mode 100755 diff --git a/src/Core/WalletSync.cpp b/src/Core/WalletSync.cpp old mode 100644 new mode 100755 diff --git a/src/Core/WalletSync.hpp b/src/Core/WalletSync.hpp old mode 100644 new mode 100755 diff --git a/src/Core/hardware/Emulator.cpp b/src/Core/hardware/Emulator.cpp old mode 100644 new mode 100755 diff --git a/src/Core/hardware/Emulator.hpp b/src/Core/hardware/Emulator.hpp old mode 100644 new mode 100755 diff --git a/src/Core/hardware/HardwareWallet.cpp b/src/Core/hardware/HardwareWallet.cpp old mode 100644 new mode 100755 diff --git a/src/Core/hardware/HardwareWallet.hpp b/src/Core/hardware/HardwareWallet.hpp old mode 100644 new mode 100755 diff --git a/src/Core/hardware/Ledger.cpp b/src/Core/hardware/Ledger.cpp old mode 100644 new mode 100755 diff --git a/src/Core/hardware/Ledger.hpp b/src/Core/hardware/Ledger.hpp old mode 100644 new mode 100755 diff --git a/src/Core/hardware/Proxy.cpp b/src/Core/hardware/Proxy.cpp old mode 100644 new mode 100755 diff --git a/src/Core/hardware/Proxy.hpp b/src/Core/hardware/Proxy.hpp old mode 100644 new mode 100755 diff --git a/src/Core/hardware/Trezor.cpp b/src/Core/hardware/Trezor.cpp old mode 100644 new mode 100755 diff --git a/src/Core/hardware/Trezor.hpp b/src/Core/hardware/Trezor.hpp old mode 100644 new mode 100755 diff --git a/src/Core/hardware/ledger/bytecoin_ledger_api.h b/src/Core/hardware/ledger/bytecoin_ledger_api.h old mode 100644 new mode 100755 diff --git a/src/Core/hardware/trezor/messages-bytecoin.cpp b/src/Core/hardware/trezor/messages-bytecoin.cpp old mode 100644 new mode 100755 diff --git a/src/Core/hardware/trezor/messages-bytecoin.hpp b/src/Core/hardware/trezor/messages-bytecoin.hpp old mode 100644 new mode 100755 diff --git a/src/Core/hardware/trezor/messages-common.cpp b/src/Core/hardware/trezor/messages-common.cpp old mode 100644 new mode 100755 diff --git a/src/Core/hardware/trezor/messages-common.hpp b/src/Core/hardware/trezor/messages-common.hpp old mode 100644 new mode 100755 diff --git a/src/Core/hardware/trezor/messages.hpp b/src/Core/hardware/trezor/messages.hpp old mode 100644 new mode 100755 diff --git a/src/Core/hardware/trezor/protobuf.hpp b/src/Core/hardware/trezor/protobuf.hpp old mode 100644 new mode 100755 diff --git a/src/CryptoNote.cpp b/src/CryptoNote.cpp old mode 100644 new mode 100755 diff --git a/src/CryptoNote.hpp b/src/CryptoNote.hpp old mode 100644 new mode 100755 diff --git a/src/CryptoNoteConfig.hpp b/src/CryptoNoteConfig.hpp old mode 100644 new mode 100755 index 337f001a..15547009 --- a/src/CryptoNoteConfig.hpp +++ b/src/CryptoNoteConfig.hpp @@ -1,240 +1,199 @@ -// Copyright (c) 2012-2018, The CryptoNote developers, The Bytecoin developers. -// Licensed under the GNU Lesser General Public License. See LICENSE for details. - -#pragma once - -#include -#include -#include -#include "CryptoNote.hpp" -#include "common/StringTools.hpp" -#include "p2p/P2pProtocolTypes.hpp" - -#ifndef CRYPTONOTE_NAME -#error CRYPTONOTE_NAME must be defined before compiling project -#endif - -// All values below should only be used in code through Currency and Config classes, never directly. -// This approach allows unlimited customization through config file/command line parameters -// Never include this header into other headers -namespace cn { namespace parameters { - -// Magics -const char GENESIS_COINBASE_TX_HEX[] = - "010a01ff0001ffffffffffff0f029b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd08807121013c086a48c15fb637a96991bc6d53caf77068b5ba6eeb3c82357228c49790584a"; -// Technically, we should not have predefined genesis block, first hard checkpoint is enough. This is bitcoin legacy. -constexpr UUID BYTECOIN_NETWORK = common::pfh("11100111110001011011001210110110"); // Bender's nightmare - -const Height UPGRADE_HEIGHT_V2 = 546603; -const Height UPGRADE_HEIGHT_V3 = 985549; -const Height UPGRADE_HEIGHT_V4 = 1792117; -const Height KEY_IMAGE_SUBGROUP_CHECKING_HEIGHT = 1267000; - -// Radical simplification of consensus rules starts from versions -// Amethyst blocks can contain v1 transactions -const uint8_t BLOCK_VERSION_AMETHYST = 4; -const uint8_t TRANSACTION_VERSION_AMETHYST = 4; - -const size_t MINIMUM_ANONYMITY_AMETHYST = 3; - -// Emission and formats -const Amount MONEY_SUPPLY = std::numeric_limits::max(); -const unsigned EMISSION_SPEED_FACTOR = 18; -static_assert(EMISSION_SPEED_FACTOR > 0 && EMISSION_SPEED_FACTOR <= 8 * sizeof(uint64_t), "Bad EMISSION_SPEED_FACTOR"); - -const size_t DISPLAY_DECIMAL_POINT = 8; -const Amount MIN_DUST_THRESHOLD = 1000000; // Everything smaller will be split in groups of 3 digits -const Amount MAX_DUST_THRESHOLD = 30000000000000000; // Everything larger is dust because very few coins -const Amount SELF_DUST_THRESHOLD = 1000; // forfeit outputs smaller than this in a change - -const uint64_t ADDRESS_BASE58_PREFIX = 6; // legacy addresses start with "2" -const uint64_t ADDRESS_BASE58_PREFIX_AMETHYST = 572238; // addresses start with "bcnZ", varintdata={0xce, 0xf6, 0x22} -const uint64_t SENDPROOF_BASE58_PREFIX = 86762904402638; -// proofs start with "bcn1PRoof", varintdata={0xce, 0xf5, 0xe2, 0x80, 0x91, 0xdd, 0x13} -const uint64_t VIEWONLYWALLET_BASE58_PREFIX = 3904523549390; -// wallets start with "bcnAUDit", varintdata={0xce, 0xf5, 0xf4, 0xbd, 0xd1, 0x71} -const char BLOCKS_FILENAME[] = "blocks.bin"; -const char BLOCKINDEXES_FILENAME[] = "blockindexes.bin"; - -// Difficulty and rewards -const Timestamp DIFFICULTY_TARGET = 120; -const Height EXPECTED_NUMBER_OF_BLOCKS_PER_DAY = 24 * 60 * 60 / DIFFICULTY_TARGET; - -const Difficulty MINIMUM_DIFFICULTY_V1 = 1; // Genesis and some first blocks in main net -const Difficulty MINIMUM_DIFFICULTY = 100000; - -const Height DIFFICULTY_WINDOW = 720; -const Height DIFFICULTY_CUT = 60; // out-of-family timestamps to cut after sorting -const Height DIFFICULTY_LAG = 15; // skip last blocks for difficulty calcs (against lowering difficulty attack) - -static_assert(DIFFICULTY_WINDOW >= 2, "Bad DIFFICULTY_WINDOW"); -static_assert(2 * DIFFICULTY_CUT <= DIFFICULTY_WINDOW - 2, "Bad DIFFICULTY_WINDOW or DIFFICULTY_CUT"); - -// Upgrade voting -const Height UPGRADE_VOTING_PERCENT = 90; -const Height UPGRADE_VOTING_WINDOW = EXPECTED_NUMBER_OF_BLOCKS_PER_DAY; -const Height UPGRADE_WINDOW = EXPECTED_NUMBER_OF_BLOCKS_PER_DAY * 7; // Delay after voting -static_assert(60 <= UPGRADE_VOTING_PERCENT && UPGRADE_VOTING_PERCENT <= 100, "Bad UPGRADE_VOTING_PERCENT"); -static_assert(UPGRADE_VOTING_WINDOW > 1, "Bad UPGRADE_VOTING_WINDOW"); - -// Timestamps -const Timestamp BLOCK_FUTURE_TIME_LIMIT = 60 * 60 * 2; -const Height BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V1_3 = 60; -const Height BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW = 59; -static_assert(BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW % 2 == 1, - "This window must be uneven for median timestamp to grow monotonically"); - -// Locking by timestamp and by block -const Height MAX_BLOCK_NUMBER = 500000000; - -// Legacy pre amethyst locking constants -const Height LOCKED_TX_ALLOWED_DELTA_BLOCKS = 1; - -constexpr Timestamp LOCKED_TX_ALLOWED_DELTA_SECONDS(Timestamp difficulty_target) { - return difficulty_target * LOCKED_TX_ALLOWED_DELTA_BLOCKS; -} - -const Height MINED_MONEY_UNLOCK_WINDOW = 10; - -// Size limits -const size_t MAX_HEADER_SIZE = 2048; -const size_t BLOCK_CAPACITY_VOTE_MIN = 100 * 1000; // min block size -const size_t BLOCK_CAPACITY_VOTE_MAX = 2000 * 1000; // max block size -static_assert(BLOCK_CAPACITY_VOTE_MAX >= BLOCK_CAPACITY_VOTE_MIN, "Bad TRANSACTIONS_SIZE_VOTE"); -const Height BLOCK_CAPACITY_VOTE_WINDOW = 11; - -// Legacy pre amethyst size limits -const size_t MINIMUM_SIZE_MEDIAN_V3 = 100000; -const size_t MINIMUM_SIZE_MEDIAN_V2 = 20000; -const size_t MINIMUM_SIZE_MEDIAN_V1 = 10000; - -const Height MEIDAN_BLOCK_SIZE_WINDOW = 100; -const size_t MAX_BLOCK_SIZE_INITIAL = 20 * 1024; // block transactions size -const size_t MAX_BLOCK_SIZE_GROWTH_PER_YEAR = 100 * 1024; // block transactions size - -// P2p ports, not strictly part of consensus -const uint16_t P2P_DEFAULT_PORT = 8080; -const uint16_t RPC_DEFAULT_PORT = 8081; -const uint16_t WALLET_RPC_DEFAULT_PORT = 8070; - -// We do not want runtime conversion, so compile-time converter -constexpr PublicKey P2P_STAT_TRUSTED_PUBLIC_KEY = - common::pfh("E29507CA55455F37A3B783EE2C5123B8B6A34A0C5CAAE050922C6254161480C1"); - -constexpr PublicKey CHECKPOINT_PUBLIC_KEYS[] = { - common::pfh("b397e789ba603046d5750bbf490e1569f55dc9cf1f91edd2605d55d7bc3603fc"), - common::pfh("10fdd8f7331304b2818b86158be07e5e71441a3e96fccc3451f4c12862ce2d75"), - common::pfh("6e03debc66cfeabe0fb8720f4ed3a433a16a40dc9b72e6d14679f0b8a784cd58"), - common::pfh("7afcd21a758f0568d536bec2e613c8470c086c97f14dfec3f2a744492ad02f0f"), - common::pfh("64aadc345b4e12c10ae19e02a1536550abf0cb5118e9ad7d4c7184215a551240"), - common::pfh("247eb4681afe8fbbf09fa7145249be27f8afdaefb023850e1399aaf49747d5e4"), - common::pfh("eb39db3c11b09c637a06122e48d0ee88603e7b216dda01901daa27c485d82eff")}; -constexpr PublicKey CHECKPOINT_PUBLIC_KEYS_TESTNET[] = { - common::pfh("577ac6a6cdc5e0114c5a7e6338f1332fd0684e2aaf7aa3efb415e9f623d04bf5"), - common::pfh("49950afc665e2f23354c03559f67e01e4f23fe2f30c6c6037b4de6dbd914ed80"), - common::pfh("07f8bba2577c0bfd9f5dc8af7319b6acbbde22bf95678927c707bb42e22fd157"), - common::pfh("9d385d34b2b4a4eb21cc1eab33ad0763b43423bdf9921db20ca5b13edd595b35"), - common::pfh("7b897d24abb76a31230b1de982be9b32a5f12dae716bbec4804a3866555e5cad"), - common::pfh("89ccf482916c8e381e344542537d908be76a0180e4043bf748407bd7b3b7193c"), - common::pfh("005d18764a7c4514d217d55f39633c8145e25afe91fd84837fc1a9ab5e048e8e")}; -constexpr PublicKey CHECKPOINT_PUBLIC_KEYS_STAGENET[] = { - common::pfh("11bcb3340a24e7cc2d3e4faa4c4f66ff7ef2813c1ae49e4f8b545d14b0f79bdc"), - common::pfh("32be85c1afd74f924a7487a76dda12b4a9925adf6212c903d7188ebd16ce8495"), - common::pfh("d1789d5103bc8328285124dfc77d3fd3c5d3d76e70616bb409d84d3f335326cf"), - common::pfh("8ccd5e4828b4b3d785e0f9c910771271ad40e9b1f427db1df9021a7a4083288c"), - common::pfh("6269b60e38cd1879807e3591f1e19b936c4d156a3d15b0693a8700ee7770e431"), - common::pfh("c9b8aa2f09fb81f77c135d1eb23cd7eac5b66c409058d5b53f724a1b887fe70f"), - common::pfh("62020c71bbf2447ee588b28c15430434f2ceac8443c40b6e48b627e437110981")}; - -const char *const SEED_NODES[] = { - "207.246.127.160:8080", "108.61.174.232:8080", "45.32.156.183:8080", "45.76.29.96:8080"}; -const char *const SEED_NODES_STAGENET[] = { - "207.246.127.160:10080", "108.61.174.232:10080", "45.32.156.183:10080", "45.76.29.96:10080"}; -// testnet will have no seed nodes - -constexpr const HardCheckpoint CHECKPOINTS[] = { - {79000, common::pfh("cae33204e624faeb64938d80073bb7bbacc27017dc63f36c5c0f313cad455a02")}, - {140000, common::pfh("993059fb6ab92db7d80d406c67a52d9c02d873ca34b6290a12b744c970208772")}, - {200000, common::pfh("a5f74c7542077df6859f48b5b1f9c3741f29df38f91a47e14c94b5696e6c3073")}, - {230580, common::pfh("32bd7cb6c68a599cf2861941f29002a5e203522b9af54f08dfced316f6459103")}, - {260000, common::pfh("f68e70b360ca194f48084da7a7fd8e0251bbb4b5587f787ca65a6f5baf3f5947")}, - {300000, common::pfh("8e80861713f68354760dc10ea6ea79f5f3ff28f39b3f0835a8637463b09d70ff")}, - {390285, common::pfh("e00bdc9bf407aeace2f3109de11889ed25894bf194231d075eddaec838097eb7")}, - {417000, common::pfh("2dc96f8fc4d4a4d76b3ed06722829a7ab09d310584b8ecedc9b578b2c458a69f")}, - {427193, common::pfh("00feabb08f2d5759ed04fd6b799a7513187478696bba2db2af10d4347134e311")}, - {453537, common::pfh("d17de6916c5aa6ffcae575309c80b0f8fdcd0a84b5fa8e41a841897d4b5a4e97")}, - {462250, common::pfh("13468d210a5ec884cf839f0259f247ccf3efef0414ac45172033d32c739beb3e")}, - {468000, common::pfh("251bcbd398b1f593193a7210934a3d87f692b2cb0c45206150f59683dd7e9ba1")}, - {480200, common::pfh("363544ac9920c778b815c2fdbcbca70a0d79b21f662913a42da9b49e859f0e5b")}, - {484500, common::pfh("5cdf2101a0a62a0ab2a1ca0c15a6212b21f6dbdc42a0b7c0bcf65ca40b7a14fb")}, - {506000, common::pfh("3d54c1132f503d98d3f0d78bb46a4503c1a19447cb348361a2232e241cb45a3c")}, - {544000, common::pfh("f69dc61b6a63217f32fa64d5d0f9bd920873f57dfd79ebe1d7d6fb1345b56fe0")}, - {553300, common::pfh("f7a5076b887ce5f4bb95b2729c0edb6f077a463f04f1bffe7f5cb0b16bb8aa5f")}, - {580000, common::pfh("93aea06936fa4dc0a84c9109c9d5f0e1b0815f96898171e42fd2973d262ed9ac")}, - {602000, common::pfh("a05fd2fccbb5f567ece940ebb62a82fdb1517ff5696551ae704e5f0ef8edb979")}, - {623000, common::pfh("7c92dd374efd0221065c7d98fce0568a1a1c130b5da28bb3f338cdc367b93d0b")}, - {645000, common::pfh("1eeba944c0dd6b9a1228a425a74076fbdbeaf9b657ba7ef02547d99f971de70d")}, - {667000, common::pfh("a020c8fcaa567845d04b520bb7ebe721e097a9bed2bdb8971081f933b5b42995")}, - {689000, common::pfh("212ec2698c5ebd15d6242d59f36c2d186d11bb47c58054f476dd8e6b1c7f0008")}, - {713000, common::pfh("a03f836c4a19f907cd6cac095eb6f56f5279ca2d1303fb7f826750dcb9025495")}, - {750300, common::pfh("5117631dbeb5c14748a91127a515ecbf13f6849e14fda7ee03cd55da41f1710c")}, - {780000, common::pfh("8dd55a9bae429e3685b90317281e633917023d3512eb7f37372209d1a5fc1070")}, - {785500, common::pfh("de1a487d70964d25ed6f7de196866f357a293e867ee81313e7fd0352d0126bdd")}, - {789000, common::pfh("acef490bbccce3b7b7ae8554a414f55413fbf4ca1472c6359b126a4439bd9f01")}, - {796000, common::pfh("04e387a00d35db21d4d93d04040b31f22573972a7e61d72cc07d0ab69bcb9c44")}, - {800000, common::pfh("d7fa4eea02e5ce60b949136569c0ea7ac71ea46e0065311054072ac415560b86")}, - {804000, common::pfh("bcc8b3782499aae508c40d5587d1cc5d68281435ea9bfc6804a262047f7b934d")}, - {810500, common::pfh("302b2349f221232820adc3dadafd8a61b035491e33af669c78a687949eb0a381")}, - {816000, common::pfh("32b7fdd4e4d715db81f8f09f4ba5e5c78e8113f2804d61a57378baee479ce745")}, - {822000, common::pfh("a3c9603c6813a0dc0efc40db288c356d1a7f02d1d2e47bee04346e73715f8984")}, - {841000, common::pfh("2cffb6504ee38f708a6256a63585f9382b3b426e64b4504236c70678bd160dce")}, - {890000, common::pfh("a7132932ea31236ce6b8775cd1380edf90b5e536ee4202c77b69a3d62445fcd2")}, - {894000, common::pfh("ae2624ea1472ecc36de0d812f21a32da2d4afc7d5770830083cbaf652209d316")}, - {979000, common::pfh("d8290eb4eedbe638f5dbadebcaf3ea434857ce96168185dc04f75b6cc1f4fda6")}, - {985548, common::pfh("8d53e0d97594755a621feaee0978c0431fc01f42b85ff76a03af8641e2009d57")}, - {985549, common::pfh("dc6f8d9319282475c981896b98ff9772ae2499533c2302c32faf65115aaf2554")}, - {996000, common::pfh("c9a9243049acc7773a3e58ae354d66f8ea83996ece93ffbaad0b8b42b5fb7223")}, - {1021000, common::pfh("a0c4107d327ffeb31dabe135a7124191b0a5ef7c4fa34f06babc1f0546ab938e")}, - {1039000, common::pfh("8c9208940fc92539fac98cc658b95d240635f8729ee8bd756d6bdbab52de2c04")}, - {1170000, common::pfh("f48441157749e89687dfa6edec2128ff332bdaa9eb139f2330a193e3139d2980")}, - {1268000, common::pfh("d49fcaec1d53095e2c244913f123bfd4b26eabb6d75aca7b77a00de8aa8ac680")}, - {1272000, common::pfh("2fb2c50328c8345d2f0a16b3ec4ea680a8a93730358494265ada9edbb9bfa1a6")}, - {1273000, common::pfh("496a9238c654d79c48d269224aa75d61f51831bae6dc744f5e709bec11c7c9f2")}, - {1278000, common::pfh("de0225cd279ca27cc8d4f8da1b5b92ba0112e48b3777b8c50301846ccfc9146b")}, - {1283000, common::pfh("826043db95e9801f038f254d223ce0d0912da269dcce1461b5f0f05ddfae9e1c")}, - {1324000, common::pfh("981e6f6871a7c295b56c5ce544adb5a7d52540ee23e15474b4357c7728952fef")}, - {1329000, common::pfh("b88ed8dfe95a19bd6377f77c01d87df9cf7bd14cd6de7ec616beca95deb1fc85")}, - {1343000, common::pfh("1696231b026b4e10412b16d65ba036c9750d287ab76da7e25efd4ba3fa9ed999")}, - {1372000, common::pfh("55e02f544df808a12d3c2809b8c7490f8b0729aef196745240e94522c69a7181")}, - {1398000, common::pfh("5e9eaf424ffba3957c569efc119a6e9ba0a636af99c44ea4cb921654ba634146")}, - {1422000, common::pfh("edae8fec5d6572c84b4c6c794922b1e4ce97d82a057c77235407e29568525a46")}, - {1451000, common::pfh("327814e8ee24650ad95d62b61e066d884abbb9d5ac18cd258baf24086c2a0882")}, - {1479000, common::pfh("16c9a464514685d325ac06b82e4476d0d5467c59b733f5fbd950e9931e58d18c")}, - {1510000, common::pfh("fcdc93636c47266f6d71606456d5767b7bc4567adbe8055b6d72b56401b48ece")}, - {1540000, common::pfh("8014ee1613e13aea282f95b343cf46c376cf8050f801a145665ae80e33a867a1")}, - {1560000, common::pfh("1a28c09c74b4b1ad97e4d65b99f97e62aa4f225be5b33017efc07c5c708b83ef")}, - {1579000, common::pfh("debfa79d14ff49dc7e8c24e5e27a22f9a67819124a7dcd187c67493a969044be")}, - {1605000, common::pfh("a34a41f2b5091f28f234b55a6255a9727fed355ca41233d59f779b2f87d1a359")}, - {1628000, common::pfh("4e7b55e53402c71c45cb97f8ed78ed3f128c802008c83b0153aa52c30b740c68")}, - {1670000, common::pfh("58770b800108c72512a386783fd0a4326c74dc9f99b538337a195945b89a9a6f")}, - {1709000, common::pfh("82185d3365e730074c4804b151c19d29ee4b2407772467853f96839567d8b45a")}, - {1740000, common::pfh("769ef18196c1ebeab9ef372e40475c2ce8c65ca7e22b0894e41f3d675343ab49")}, - {1764000, common::pfh("b79c80df808d6447965e5e75d0e2a40ab07e591e9efa8efa1be3945fe3278669")}, - {1795000, common::pfh("db3f1f99b45d8e771dce12eeadd2e9258743d0d7094f2a78b3d9a2af283d78a6")}, - {1826000, common::pfh("5edc3138a77631ee7ada27d8c5cf6307577f762b83399d25f3ea9eec529f23b6")}}; - -// When adding checkpoint and BEFORE release, you MUST check that daemon fully syncs both mainnet and stagenet. - -// Be extra careful when setting checkpoint around consensus update heights. Follow rules: -// 1. never set checkpoint after or to height where required # of votes for upgrade was gathered -// 2. never set checkpoint before height where upgrade happened (with desired major version) -// 3. after setting checkpoint after upgrade, modify upgrade_heights array - -constexpr const HardCheckpoint CHECKPOINTS_STAGENET[] = { - {450, common::pfh("c69823a6b3e0c1f724411e697219a9d31a2df900cb49bb0488b1a91a9989a805")}, - {30000, common::pfh("4a3b02206d120bab6c3bef4a7bcbc1934b5327c27c181d790f4db407dc92c640")}, - {49000, common::pfh("1960a677cda6afd47dd4a928bf876b7cb7c9bd86107e3193ca9b0fd0926bad4c")}, - {70000, common::pfh("10ce87ab253c1142414a700336795057781572b5d9f026c57463ae420e456240")}, - {101000, common::pfh("6cbba1769cf623518c13656d608185f3085dfb47672d561e77ed9b0d3b295391")}, - {122000, common::pfh("3e8e49a09bf2ccdcbd618ed898c44e23fcb6df3d7a33bfadc419af048651bfd0")}}; -}} // namespace cn::parameters +// Copyright (c) 2012-2018, The CryptoNote developers, The Bytecoin developers. +// Licensed under the GNU Lesser General Public License. See LICENSE for details. + +#pragma once + +#include +#include +#include +#include "CryptoNote.hpp" +#include "common/StringTools.hpp" +#include "p2p/P2pProtocolTypes.hpp" + +#ifndef CRYPTONOTE_NAME +#error CRYPTONOTE_NAME must be defined before compiling project +#endif + +// All values below should only be used in code through Currency and Config classes, never directly. +// This approach allows unlimited customization through config file/command line parameters +// Never include this header into other headers +namespace cn { namespace parameters { + +// Magics +const char GENESIS_COINBASE_TX_HEX[] = + "010a01ff0001" "ccd4dfc60302" "9b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd088071" "2101" "a9fb59d721aa495decac1477605a1e6530e1615c0eace9333e8a7fde90fff908"; +// Technically, we should not have predefined genesis block, first hard checkpoint is enough. This is bitcoin legacy. +constexpr UUID BYTECOIN_NETWORK = common::pfh("11100111110001011011001210110111"); // Bender's nightmare + +const Height UPGRADE_HEIGHT_V2 = 2; +const Height UPGRADE_HEIGHT_V3 = 3; +const Height UPGRADE_HEIGHT_V4 = 4; +const Height KEY_IMAGE_SUBGROUP_CHECKING_HEIGHT = 5; + +// Radical simplification of consensus rules starts from versions +// Amethyst blocks can contain v1 transactions +const uint8_t BLOCK_VERSION_AMETHYST = 4; +const uint8_t TRANSACTION_VERSION_AMETHYST = 4; + +const size_t MINIMUM_ANONYMITY_AMETHYST = 3; + +// Emission and formats +const Amount MONEY_SUPPLY = 2000000000000000; //std::numeric_limits::max(); +const unsigned EMISSION_SPEED_FACTOR = 21; +static_assert(EMISSION_SPEED_FACTOR > 0 && EMISSION_SPEED_FACTOR <= 8 * sizeof(uint64_t), "Bad EMISSION_SPEED_FACTOR"); + +const size_t DISPLAY_DECIMAL_POINT = 8; +const Amount MIN_DUST_THRESHOLD = 1000000; // Everything smaller will be split in groups of 3 digits +const Amount MAX_DUST_THRESHOLD = 30000000000000000; // Everything larger is dust because very few coins +const Amount SELF_DUST_THRESHOLD = 1000; // forfeit outputs smaller than this in a change + +const uint64_t ADDRESS_BASE58_PREFIX = 146; // RR +const uint64_t ADDRESS_BASE58_PREFIX_AMETHYST = 1717961; // addresses start with "amx1" +const uint64_t SENDPROOF_BASE58_PREFIX = 2971951985097; // proofs start with "amaPRoof" +const uint64_t VIEWONLYWALLET_BASE58_PREFIX = 57429191753; // wallets start with "amAUDit" +const char BLOCKS_FILENAME[] = "blocks.bin"; +const char BLOCKINDEXES_FILENAME[] = "blockindexes.bin"; + +// Difficulty and rewards +const Timestamp DIFFICULTY_TARGET = 120; +const Timestamp DIFFICULTY_WINDOWS_LWMA = 90; +const Height EXPECTED_NUMBER_OF_BLOCKS_PER_DAY = 24 * 60 * 60 / DIFFICULTY_TARGET; + +const Difficulty MINIMUM_DIFFICULTY_V1 = 1; // Genesis and some first blocks in main net +const Difficulty MINIMUM_DIFFICULTY = 5000; + +const Height DIFFICULTY_WINDOW = 720; +const Height DIFFICULTY_CUT = 60; // out-of-family timestamps to cut after sorting +const Height DIFFICULTY_LAG = 15; // skip last blocks for difficulty calcs (against lowering difficulty attack) + +static_assert(DIFFICULTY_WINDOW >= 2, "Bad DIFFICULTY_WINDOW"); +static_assert(2 * DIFFICULTY_CUT <= DIFFICULTY_WINDOW - 2, "Bad DIFFICULTY_WINDOW or DIFFICULTY_CUT"); + +// Upgrade voting +const Height UPGRADE_VOTING_PERCENT = 90; +const Height UPGRADE_VOTING_WINDOW = EXPECTED_NUMBER_OF_BLOCKS_PER_DAY; +const Height UPGRADE_WINDOW = EXPECTED_NUMBER_OF_BLOCKS_PER_DAY * 7; // Delay after voting +static_assert(60 <= UPGRADE_VOTING_PERCENT && UPGRADE_VOTING_PERCENT <= 100, "Bad UPGRADE_VOTING_PERCENT"); +static_assert(UPGRADE_VOTING_WINDOW > 1, "Bad UPGRADE_VOTING_WINDOW"); + +// Timestamps +const Timestamp BLOCK_FUTURE_TIME_LIMIT = 60 * 60 * 2; +const Height BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW_V1_3 = 60; +const Height BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW = 59; +static_assert(BLOCKCHAIN_TIMESTAMP_CHECK_WINDOW % 2 == 1, + "This window must be uneven for median timestamp to grow monotonically"); + +// Locking by timestamp and by block +const Height MAX_BLOCK_NUMBER = 500000000; + +// Legacy pre amethyst locking constants +const Height LOCKED_TX_ALLOWED_DELTA_BLOCKS = 1; + +constexpr Timestamp LOCKED_TX_ALLOWED_DELTA_SECONDS(Timestamp difficulty_target) { + return difficulty_target * LOCKED_TX_ALLOWED_DELTA_BLOCKS; +} + +const Height MINED_MONEY_UNLOCK_WINDOW = 10; + +// Size limits +const size_t MAX_HEADER_SIZE = 2048; +const size_t BLOCK_CAPACITY_VOTE_MIN = 100 * 1000; // min block size +const size_t BLOCK_CAPACITY_VOTE_MAX = 2000 * 1000; // max block size +static_assert(BLOCK_CAPACITY_VOTE_MAX >= BLOCK_CAPACITY_VOTE_MIN, "Bad TRANSACTIONS_SIZE_VOTE"); +const Height BLOCK_CAPACITY_VOTE_WINDOW = 11; + +// Legacy pre amethyst size limits +const size_t MINIMUM_SIZE_MEDIAN_V3 = 100000; +const size_t MINIMUM_SIZE_MEDIAN_V2 = 20000; +const size_t MINIMUM_SIZE_MEDIAN_V1 = 10000; + +const Height MEIDAN_BLOCK_SIZE_WINDOW = 100; +const size_t MAX_BLOCK_SIZE_INITIAL = 20 * 1024; // block transactions size +const size_t MAX_BLOCK_SIZE_GROWTH_PER_YEAR = 100 * 1024; // block transactions size + +// P2p ports, not strictly part of consensus +const uint16_t P2P_DEFAULT_PORT = 58080; +const uint16_t RPC_DEFAULT_PORT = 58081; +const uint16_t WALLET_RPC_DEFAULT_PORT = 58082; + +// We do not want runtime conversion, so compile-time converter +constexpr PublicKey P2P_STAT_TRUSTED_PUBLIC_KEY = + common::pfh("E29507CA55455F37A3B783EE2C5123B8B6A34A0C5CAAE050922C6254161480C2"); + +constexpr PublicKey CHECKPOINT_PUBLIC_KEYS[] = { + common::pfh("a9fb59d721aa495decac1477605a1e6530e1615c0eace9333e8a7fde90fff908") + //common::pfh("9b2e4c0281c0b02e7c53291a94d1d0cbff8883f8024f5142ee494ffbbd088071"), + //common::pfh("6e03debc66cfeabe0fb8720f4ed3a433a16a40dc9b72e6d14679f0b8a784cd58"), + //common::pfh("7afcd21a758f0568d536bec2e613c8470c086c97f14dfec3f2a744492ad02f0f"), + //common::pfh("64aadc345b4e12c10ae19e02a1536550abf0cb5118e9ad7d4c7184215a551240"), + //common::pfh("247eb4681afe8fbbf09fa7145249be27f8afdaefb023850e1399aaf49747d5e4"), + //common::pfh("eb39db3c11b09c637a06122e48d0ee88603e7b216dda01901daa27c485d82eff") +}; +constexpr PublicKey CHECKPOINT_PUBLIC_KEYS_TESTNET[] = { + common::pfh("a9fb59d721aa495decac1477605a1e6530e1615c0eace9333e8a7fde90fff908") + //common::pfh("577ac6a6cdc5e0114c5a7e6338f1332fd0684e2aaf7aa3efb415e9f623d04bf5"), + //common::pfh("49950afc665e2f23354c03559f67e01e4f23fe2f30c6c6037b4de6dbd914ed80"), + //common::pfh("07f8bba2577c0bfd9f5dc8af7319b6acbbde22bf95678927c707bb42e22fd157"), + //common::pfh("9d385d34b2b4a4eb21cc1eab33ad0763b43423bdf9921db20ca5b13edd595b35"), + //common::pfh("7b897d24abb76a31230b1de982be9b32a5f12dae716bbec4804a3866555e5cad"), + //common::pfh("89ccf482916c8e381e344542537d908be76a0180e4043bf748407bd7b3b7193c"), + //common::pfh("005d18764a7c4514d217d55f39633c8145e25afe91fd84837fc1a9ab5e048e8e") +}; +constexpr PublicKey CHECKPOINT_PUBLIC_KEYS_STAGENET[] = { + common::pfh("a9fb59d721aa495decac1477605a1e6530e1615c0eace9333e8a7fde90fff908") + //common::pfh("11bcb3340a24e7cc2d3e4faa4c4f66ff7ef2813c1ae49e4f8b545d14b0f79bdc"), + //common::pfh("32be85c1afd74f924a7487a76dda12b4a9925adf6212c903d7188ebd16ce8495"), + //common::pfh("d1789d5103bc8328285124dfc77d3fd3c5d3d76e70616bb409d84d3f335326cf"), + //common::pfh("8ccd5e4828b4b3d785e0f9c910771271ad40e9b1f427db1df9021a7a4083288c"), + //common::pfh("6269b60e38cd1879807e3591f1e19b936c4d156a3d15b0693a8700ee7770e431"), + //common::pfh("c9b8aa2f09fb81f77c135d1eb23cd7eac5b66c409058d5b53f724a1b887fe70f"), + //common::pfh("62020c71bbf2447ee588b28c15430434f2ceac8443c40b6e48b627e437110981") +}; + +const char *const SEED_NODES[] = { + "207.180.200.250:58080", + "207.180.200.250:57080", + "107.172.43.135:58080", + "144.76.186.203:58080", + "82.223.13.179:58080" +}; +const char *const SEED_NODES_STAGENET[] = { + "207.180.200.250:58080", + "207.180.200.250:57080", + "107.172.43.135:58080", + "144.76.186.203:58080", + "82.223.13.179:58080" +}; +// testnet will have no seed nodes + +constexpr const HardCheckpoint CHECKPOINTS[] = { + {500, common::pfh("93457e2e8942edcadaebeadda8d78b520476abfcffeb499a0b88832f3ddb2335")}, + {10000, common::pfh("8ca6dee104f34c090171ab23b3875561916122683a6c560a6e5b61f2a30368f9")}, + {20000, common::pfh("2d04a899bfca9cd42f58aa275c5957532a6e865f08fa74156875c0d38a5e9845")}, + {30000, common::pfh("36b2d490940e3badec0c4ffe50db2de196c53ad8e3738ba87d7415fc22986c61")}, + {40000, common::pfh("dab79ac59adf1e0a7c1e6f0f741ae4a8ca4d1dbeead23cf79933a53d903c2239")}, + {50000, common::pfh("ccdf7c2c4b363a57ed5fe884c712a8d4313965e1d569aafe77cae6a0c7d0dc9a")}, + {60000, common::pfh("eb2d0f3e043d111dc929bad94d4776975aed1afd906f2eafabf97cacde8f4e04")}, + {68000, common::pfh("6eea30c9b3d1884019cc00ce77d079a508aacaa930f485679a6ee794c045ed3a")} + ,{109739, common::pfh("123e88f375ca4a62a5bbcd29a975944961785b2d63f5874765880b4d2b10e0c5")} + ,{109740, common::pfh("1e3d052a10895e40d13bdb823c0f158f76bb11661f4420e3f7cb607b150aed83")} + ,{130175, common::pfh("89594bc8ae96d9f9939348b1ca29a6322a8c9f4c2968524c27fca9078012676f")} + ,{130176, common::pfh("dd8244dbd2022c2dc15737d712f4744ff1398223f7107af533924d6a9c57e3bd")} + ,{130177, common::pfh("52532259e58f3851f22f7d4564cfd442b762d0bc71d2db3a26d21ebb1c1f4f94")} + ,{132350, common::pfh("a4098dae7962c2dc07f4ba9c3bf5ea6e9ba60ad523e87392225e3e266d11ace5")} + ,{132351, common::pfh("107af3a99654f501ac29d90aa0a32106b5052b5de1ce97e3326b9e9a678d1361")} + ,{139999, common::pfh("1e8baa8031e80eb86e5464cb4aeee550945dd5e2a1eede348d58da1505465664")} +}; + +// When adding checkpoint and BEFORE release, you MUST check that daemon fully syncs both mainnet and stagenet. + +// Be extra careful when setting checkpoint around consensus update heights. Follow rules: +// 1. never set checkpoint after or to height where required # of votes for upgrade was gathered +// 2. never set checkpoint before height where upgrade happened (with desired major version) +// 3. after setting checkpoint after upgrade, modify upgrade_heights array + +constexpr const HardCheckpoint CHECKPOINTS_STAGENET[] = { + {(Height)(-1),common::pfh("0000000000000000000000000000000000000000000000000000000000000000")} +}; + +}} // namespace cn::parameters diff --git a/src/bytecoin.ico b/src/bytecoin.ico old mode 100644 new mode 100755 index 20a8ea75..f5219b1d Binary files a/src/bytecoin.ico and b/src/bytecoin.ico differ diff --git a/src/bytecoin.rc b/src/bytecoin.rc old mode 100644 new mode 100755 index 75c8d348..566fdbb4 --- a/src/bytecoin.rc +++ b/src/bytecoin.rc @@ -20,13 +20,13 @@ BEGIN BEGIN BLOCK "040904b0" BEGIN - VALUE "CompanyName", "Bytecoin Developers" - VALUE "FileDescription", "Bytecoin" + VALUE "CompanyName", "Armor Network Developers" + VALUE "FileDescription", "Armor Network" VALUE "FileVersion", bytecoin_VERSION_STRING - VALUE "InternalName", "Bytecoin" - VALUE "LegalCopyright", "Copyright (C) Bytecoin Developers 2012-2018" - VALUE "OriginalFilename", "Bytecoin" - VALUE "ProductName", "Bytecoin" + VALUE "InternalName", "Armor Network" + VALUE "LegalCopyright", "Armor Network Developers 2020-2021 Copyright (C) Bytecoin Developers 2012-2018" + VALUE "OriginalFilename", "Armor" + VALUE "ProductName", "Armor" VALUE "ProductVersion", bytecoin_VERSION_STRING END END diff --git a/src/common/BIPs.cpp b/src/common/BIPs.cpp old mode 100644 new mode 100755 index 24d0c9f3..a4d9dcec --- a/src/common/BIPs.cpp +++ b/src/common/BIPs.cpp @@ -374,7 +374,7 @@ std::string Bip32Key::create_random_bip39_mnemonic(size_t bits) { const size_t cs_bits = bits / 32; const size_t should_be_words = (bits + cs_bits) / 11; std::vector ent_data(bits / 8); - crypto::generate_random_bytes(ent_data.data(), ent_data.size()); + crypto::generate_random_bytes(ent_data.data(), ent_data.size()); unsigned char hash[32]; sha256_checked(ent_data.data(), ent_data.size(), hash); diff --git a/src/common/BIPs.hpp b/src/common/BIPs.hpp old mode 100644 new mode 100755 diff --git a/src/common/Base58.cpp b/src/common/Base58.cpp old mode 100644 new mode 100755 diff --git a/src/common/Base58.hpp b/src/common/Base58.hpp old mode 100644 new mode 100755 diff --git a/src/common/Base64.cpp b/src/common/Base64.cpp old mode 100644 new mode 100755 diff --git a/src/common/Base64.hpp b/src/common/Base64.hpp old mode 100644 new mode 100755 diff --git a/src/common/BinaryArray.cpp b/src/common/BinaryArray.cpp old mode 100644 new mode 100755 diff --git a/src/common/BinaryArray.hpp b/src/common/BinaryArray.hpp old mode 100644 new mode 100755 diff --git a/src/common/CommandLine.cpp b/src/common/CommandLine.cpp old mode 100644 new mode 100755 diff --git a/src/common/CommandLine.hpp b/src/common/CommandLine.hpp old mode 100644 new mode 100755 diff --git a/src/common/ConsoleTools.cpp b/src/common/ConsoleTools.cpp old mode 100644 new mode 100755 diff --git a/src/common/ConsoleTools.hpp b/src/common/ConsoleTools.hpp old mode 100644 new mode 100755 diff --git a/src/common/Int128.cpp b/src/common/Int128.cpp old mode 100644 new mode 100755 diff --git a/src/common/Int128.hpp b/src/common/Int128.hpp old mode 100644 new mode 100755 diff --git a/src/common/Invariant.cpp b/src/common/Invariant.cpp old mode 100644 new mode 100755 diff --git a/src/common/Invariant.hpp b/src/common/Invariant.hpp old mode 100644 new mode 100755 diff --git a/src/common/Ipv4Address.cpp b/src/common/Ipv4Address.cpp old mode 100644 new mode 100755 diff --git a/src/common/Ipv4Address.hpp b/src/common/Ipv4Address.hpp old mode 100644 new mode 100755 diff --git a/src/common/JsonValue.cpp b/src/common/JsonValue.cpp old mode 100644 new mode 100755 diff --git a/src/common/JsonValue.hpp b/src/common/JsonValue.hpp old mode 100644 new mode 100755 diff --git a/src/common/Math.hpp b/src/common/Math.hpp old mode 100644 new mode 100755 diff --git a/src/common/MemoryStreams.cpp b/src/common/MemoryStreams.cpp old mode 100644 new mode 100755 diff --git a/src/common/MemoryStreams.hpp b/src/common/MemoryStreams.hpp old mode 100644 new mode 100755 diff --git a/src/common/Nocopy.hpp b/src/common/Nocopy.hpp old mode 100644 new mode 100755 diff --git a/src/common/ScopeExit.hpp b/src/common/ScopeExit.hpp old mode 100644 new mode 100755 diff --git a/src/common/Streams.cpp b/src/common/Streams.cpp old mode 100644 new mode 100755 diff --git a/src/common/Streams.hpp b/src/common/Streams.hpp old mode 100644 new mode 100755 diff --git a/src/common/StringTools.cpp b/src/common/StringTools.cpp old mode 100644 new mode 100755 diff --git a/src/common/StringTools.hpp b/src/common/StringTools.hpp old mode 100644 new mode 100755 diff --git a/src/common/StringView.cpp b/src/common/StringView.cpp old mode 100644 new mode 100755 diff --git a/src/common/StringView.hpp b/src/common/StringView.hpp old mode 100644 new mode 100755 diff --git a/src/common/Varint.cpp b/src/common/Varint.cpp old mode 100644 new mode 100755 diff --git a/src/common/Varint.hpp b/src/common/Varint.hpp old mode 100644 new mode 100755 diff --git a/src/common/Words.cpp b/src/common/Words.cpp old mode 100644 new mode 100755 diff --git a/src/common/Words.hpp b/src/common/Words.hpp old mode 100644 new mode 100755 diff --git a/src/common/Words_generate.py b/src/common/Words_generate.py old mode 100644 new mode 100755 diff --git a/src/common/exception.cpp b/src/common/exception.cpp old mode 100644 new mode 100755 diff --git a/src/common/exception.hpp b/src/common/exception.hpp old mode 100644 new mode 100755 diff --git a/src/common/string.hpp b/src/common/string.hpp old mode 100644 new mode 100755 diff --git a/src/common/words_english.txt b/src/common/words_english.txt old mode 100644 new mode 100755 diff --git a/src/crypto/bernstein/c_types.h b/src/crypto/bernstein/c_types.h old mode 100644 new mode 100755 diff --git a/src/crypto/bernstein/chacha8.c b/src/crypto/bernstein/chacha8.c old mode 100644 new mode 100755 diff --git a/src/crypto/bernstein/chacha8.h b/src/crypto/bernstein/chacha8.h old mode 100644 new mode 100755 diff --git a/src/crypto/bernstein/crypto-ops-data.c b/src/crypto/bernstein/crypto-ops-data.c old mode 100644 new mode 100755 diff --git a/src/crypto/bernstein/crypto-ops-data.h b/src/crypto/bernstein/crypto-ops-data.h old mode 100644 new mode 100755 diff --git a/src/crypto/bernstein/crypto-ops-data_25_5.c b/src/crypto/bernstein/crypto-ops-data_25_5.c old mode 100644 new mode 100755 diff --git a/src/crypto/bernstein/crypto-ops-data_51.c b/src/crypto/bernstein/crypto-ops-data_51.c old mode 100644 new mode 100755 diff --git a/src/crypto/bernstein/crypto-ops.c b/src/crypto/bernstein/crypto-ops.c old mode 100644 new mode 100755 diff --git a/src/crypto/bernstein/crypto-ops.h b/src/crypto/bernstein/crypto-ops.h old mode 100644 new mode 100755 diff --git a/src/crypto/bernstein/fe.h b/src/crypto/bernstein/fe.h old mode 100644 new mode 100755 diff --git a/src/crypto/bernstein/fe_25_5.c b/src/crypto/bernstein/fe_25_5.c old mode 100644 new mode 100755 diff --git a/src/crypto/bernstein/fe_51.c b/src/crypto/bernstein/fe_51.c old mode 100644 new mode 100755 diff --git a/src/crypto/blake/blake256.c b/src/crypto/blake/blake256.c old mode 100644 new mode 100755 diff --git a/src/crypto/blake/blake256.h b/src/crypto/blake/blake256.h old mode 100644 new mode 100755 diff --git a/src/crypto/chacha.cpp b/src/crypto/chacha.cpp old mode 100644 new mode 100755 diff --git a/src/crypto/chacha.hpp b/src/crypto/chacha.hpp old mode 100644 new mode 100755 diff --git a/src/crypto/crypto-util.c b/src/crypto/crypto-util.c old mode 100644 new mode 100755 diff --git a/src/crypto/crypto-util.h b/src/crypto/crypto-util.h old mode 100644 new mode 100755 diff --git a/src/crypto/crypto.cpp b/src/crypto/crypto.cpp old mode 100644 new mode 100755 diff --git a/src/crypto/crypto.hpp b/src/crypto/crypto.hpp old mode 100644 new mode 100755 diff --git a/src/crypto/crypto_helpers.hpp b/src/crypto/crypto_helpers.hpp old mode 100644 new mode 100755 diff --git a/src/crypto/generic-ops.hpp b/src/crypto/generic-ops.hpp old mode 100644 new mode 100755 diff --git a/src/crypto/groestl/Groestl-opt.c b/src/crypto/groestl/Groestl-opt.c old mode 100644 new mode 100755 diff --git a/src/crypto/groestl/Groestl-opt.h b/src/crypto/groestl/Groestl-opt.h old mode 100644 new mode 100755 diff --git a/src/crypto/groestl/README.md b/src/crypto/groestl/README.md old mode 100644 new mode 100755 diff --git a/src/crypto/groestl/brg_endian.h b/src/crypto/groestl/brg_endian.h old mode 100644 new mode 100755 diff --git a/src/crypto/groestl/brg_types.h b/src/crypto/groestl/brg_types.h old mode 100644 new mode 100755 diff --git a/src/crypto/groestl/tables.h b/src/crypto/groestl/tables.h old mode 100644 new mode 100755 diff --git a/src/crypto/hash-blake.c b/src/crypto/hash-blake.c old mode 100644 new mode 100755 index 3ef20309..b76de3cb --- a/src/crypto/hash-blake.c +++ b/src/crypto/hash-blake.c @@ -10,3 +10,7 @@ void crypto_hash_extra_blake(const void *data, size_t length, struct cryptoHash *hash) { blake256_hash(hash->data, data, length); } + +void hash_extra_blake(const void *data, size_t length, unsigned char *hash) { + blake256_hash(hash, data, length); +} diff --git a/src/crypto/hash-groestl.c b/src/crypto/hash-groestl.c old mode 100644 new mode 100755 index 0b19cc3f..a89c48ea --- a/src/crypto/hash-groestl.c +++ b/src/crypto/hash-groestl.c @@ -14,3 +14,11 @@ void crypto_hash_extra_groestl(const void *data, size_t length, struct cryptoHas Update(&context, data, length * 8); Final(&context, hash->data); } + +void hash_extra_groestl(const void *data, size_t length, unsigned char *hash) { + hashState context; + + Init(&context, 256); + Update(&context, data, length * 8); + Final(&context, hash); +} diff --git a/src/crypto/hash-impl.h b/src/crypto/hash-impl.h new file mode 100644 index 00000000..b4a67e52 --- /dev/null +++ b/src/crypto/hash-impl.h @@ -0,0 +1,44 @@ +// Copyright (c) 2012-2018, The CryptoNote developers, The Bytecoin developers. +// Licensed under the GNU Lesser General Public License. See LICENSE for details. + +#pragma once + +#include +#include +#include +#include + +#include "int-util.h" +#include "hash-ops.h" + +#if defined(__cplusplus) +namespace crypto { extern "C" { +#endif + +static inline void *padd(void *p, size_t i) { + return (char *) p + i; +} + +static inline const void *cpadd(const void *p, size_t i) { + return (const char *) p + i; +} + +#pragma pack(push, 1) +union hash_state { + uint8_t b[200]; + uint64_t w[25]; +}; +#pragma pack(pop) +static_assert(sizeof(union hash_state) == 200, "Invalid structure size"); + +void hash_permutation(union hash_state *state); +void hash_process(union hash_state *state, const uint8_t *buf, size_t count); + +void hash_extra_blake(const void *data, size_t length, unsigned char *hash); +void hash_extra_groestl(const void *data, size_t length, unsigned char *hash); +void hash_extra_jh(const void *data, size_t length, unsigned char *hash); +void hash_extra_skein(const void *data, size_t length, unsigned char *hash); + +#if defined(__cplusplus) +}} +#endif diff --git a/src/crypto/hash-jh.c b/src/crypto/hash-jh.c old mode 100644 new mode 100755 index f03e2850..589a3a26 --- a/src/crypto/hash-jh.c +++ b/src/crypto/hash-jh.c @@ -9,6 +9,15 @@ #include "hash.h" #include "jh/jh.h" +enum { + HASH_SIZE = 32 +}; + void crypto_hash_extra_jh(const void *data, size_t length, struct cryptoHash *hash) { jh_hash(sizeof(struct cryptoHash) * 8, data, 8 * length, hash->data); } + +void hash_extra_jh(const void *data, size_t length, unsigned char *hash) { + int r = jh_hash(HASH_SIZE * 8, data, 8 * length, hash); + assert(SUCCESS == r); +} diff --git a/src/crypto/hash-keccak.c b/src/crypto/hash-keccak.c old mode 100644 new mode 100755 diff --git a/src/crypto/hash-ops.h b/src/crypto/hash-ops.h new file mode 100644 index 00000000..7c21b46f --- /dev/null +++ b/src/crypto/hash-ops.h @@ -0,0 +1,30 @@ +// Copyright (c) 2012-2018, The CryptoNote developers, The Bytecoin developers. +// Licensed under the GNU Lesser General Public License. See LICENSE for details. + +#include + +#pragma once + +#if defined(__cplusplus) +namespace crypto { extern "C" { +#endif + +enum { + HASH_SIZE = 32, + HASH_DATA_AREA = 136, + SLOW_HASH_CONTEXT_SIZE = 2097552 +}; + +void cn_fast_hash(const void *data, size_t length, unsigned char *hash); + +//void cn_slow_hash(void *, const void *, size_t, void *, int); +void cn_slow_hash(const void *data, size_t length, unsigned char *hash, int variant, int prehashed); + +void tree_hash(const unsigned char (*hashes)[HASH_SIZE], size_t count, unsigned char *root_hash); +size_t tree_depth(size_t count); +void tree_branch(const unsigned char (*hashes)[HASH_SIZE], size_t count, unsigned char (*branch)[HASH_SIZE]); +void tree_hash_from_branch(const unsigned char (*branch)[HASH_SIZE], size_t depth, const unsigned char *leaf, const void *path, unsigned char *root_hash); + +#if defined(__cplusplus) +}} +#endif diff --git a/src/crypto/hash-skein.c b/src/crypto/hash-skein.c old mode 100644 new mode 100755 index 0031b865..1b1ac09c --- a/src/crypto/hash-skein.c +++ b/src/crypto/hash-skein.c @@ -7,6 +7,15 @@ #include "hash.h" #include "skein/skein.h" +enum { + HASH_SIZE = 32 +}; + void crypto_hash_extra_skein(const void *data, size_t length, struct cryptoHash *hash) { skein_hash(8 * sizeof(struct cryptoHash), data, 8 * length, hash->data); } + +void hash_extra_skein(const void *data, size_t length, unsigned char *hash) { + int r = skein_hash(8 * HASH_SIZE, data, 8 * length, hash); + assert(SKEIN_SUCCESS == r); +} diff --git a/src/crypto/hash.c b/src/crypto/hash.c new file mode 100644 index 00000000..d9d675d7 --- /dev/null +++ b/src/crypto/hash.c @@ -0,0 +1,23 @@ +// Copyright (c) 2012-2018, The CryptoNote developers, The Bytecoin developers. +// Licensed under the GNU Lesser General Public License. See LICENSE for details. + +#include +#include +#include + +#include "hash-impl.h" +#include "keccak.h" + +void hash_permutation(union hash_state *state) { + keccakf((uint64_t*)state, 24); +} + +void hash_process(union hash_state *state, const uint8_t *buf, size_t count) { + keccak1600(buf, (int)count, (uint8_t*)state); +} + +void cn_fast_hash(const void *data, size_t length, unsigned char *hash) { + union hash_state state; + hash_process(&state, data, length); + memcpy(hash, &state, HASH_SIZE); +} diff --git a/src/crypto/hash.cpp b/src/crypto/hash.cpp old mode 100644 new mode 100755 diff --git a/src/crypto/hash.h b/src/crypto/hash.h old mode 100644 new mode 100755 index bf1bb597..b2673ba4 --- a/src/crypto/hash.h +++ b/src/crypto/hash.h @@ -23,8 +23,8 @@ void crypto_cn_fast_hash(const void *data, size_t length, struct cryptoHash *has // void crypto_cn_fast_hash64(const void *data, size_t length, unsigned char hash[64]); void crypto_cn_slow_hash(void *scratchpad, const void *data, size_t length, struct cryptoHash *hash); -void crypto_cn_slow_hash_platform_independent( - void *scratchpad, const void *data, size_t length, struct cryptoHash *hash); +//void crypto_cn_slow_hash_platform_independent( +// void *scratchpad, const void *data, size_t length, struct cryptoHash *hash); struct cryptoKeccakState { uint8_t b[200]; diff --git a/src/crypto/hash.hpp b/src/crypto/hash.hpp old mode 100644 new mode 100755 index b9465ffb..dbe19e23 --- a/src/crypto/hash.hpp +++ b/src/crypto/hash.hpp @@ -8,6 +8,7 @@ #include "hash.h" #include "tree-hash.h" #include "types.hpp" +#include "hash-ops.h" namespace crypto { // Cryptonight hash functions @@ -32,11 +33,13 @@ class CryptoNightContext { void operator=(const CryptoNightContext &) = delete; inline void cn_slow_hash(const void *src_data, size_t length, cryptoHash *hash) { - crypto_cn_slow_hash(data, src_data, length, hash); + //crypto_cn_slow_hash(data, src_data, length, hash); + crypto::cn_slow_hash(src_data, length, hash->data, 3, 0/*prehashed*/); } inline Hash cn_slow_hash(const void *src_data, size_t length) { Hash hash; - crypto_cn_slow_hash(data, src_data, length, &hash); + //crypto_cn_slow_hash(data, src_data, length, &hash); + crypto::cn_slow_hash(src_data, length, hash.data, 3, 0/*prehashed*/); return hash; } void *get_data() const { return data; } diff --git a/src/crypto/initializer.h b/src/crypto/initializer.h old mode 100644 new mode 100755 diff --git a/src/crypto/int-util.h b/src/crypto/int-util.h old mode 100644 new mode 100755 index ab63d7d7..18f38be3 --- a/src/crypto/int-util.h +++ b/src/crypto/int-util.h @@ -8,8 +8,6 @@ #include #include -// TODO - if possible, get rid of this crap - #if defined(_MSC_VER) #include #define LITTLE_ENDIAN 1234 @@ -21,11 +19,13 @@ extern "C" { #endif inline uint32_t rol32(uint32_t x, int r) { - static_assert(sizeof(uint32_t) == sizeof(unsigned int), "this code assumes 32-bit integers"); - return _rotl(x, r); + static_assert(sizeof(uint32_t) == sizeof(unsigned int), "this code assumes 32-bit integers"); + return _rotl(x, r); } -inline uint64_t rol64(uint64_t x, int r) { return _rotl64(x, r); } +inline uint64_t rol64(uint64_t x, int r) { + return _rotl64(x, r); +} #if defined(__cplusplus) } #endif @@ -36,9 +36,13 @@ inline uint64_t rol64(uint64_t x, int r) { return _rotl64(x, r); } #if defined(__cplusplus) extern "C" { #endif -static inline uint32_t rol32(uint32_t x, int r) { return (x << (r & 31)) | (x >> (-r & 31)); } +static inline uint32_t rol32(uint32_t x, int r) { + return (x << (r & 31)) | (x >> (-r & 31)); +} -static inline uint64_t rol64(uint64_t x, int r) { return (x << (r & 63)) | (x >> (-r & 63)); } +static inline uint64_t rol64(uint64_t x, int r) { + return (x << (r & 63)) | (x >> (-r & 63)); +} #if defined(__cplusplus) } #endif @@ -49,84 +53,153 @@ static inline uint64_t rol64(uint64_t x, int r) { return (x << (r & 63)) | (x >> extern "C" { #endif -static inline uint64_t hi_dword(uint64_t val) { return val >> 32; } +static inline uint64_t hi_dword(uint64_t val) { + return val >> 32; +} -static inline uint64_t lo_dword(uint64_t val) { return val & 0xFFFFFFFF; } +static inline uint64_t lo_dword(uint64_t val) { + return val & 0xFFFFFFFF; +} -static inline uint64_t mul128(uint64_t multiplier, uint64_t multiplicand, uint64_t *product_hi) { +static inline uint64_t mul128(uint64_t multiplier, uint64_t multiplicand, uint64_t * product_hi) { #if defined(__GNUC__) && defined(__x86_64__) uint64_t hi, lo; - __asm__("mulq %3\n\t" : "=d"(hi), "=a"(lo) : "%a"(multiplier), "rm"(multiplicand) : "cc"); + __asm__("mulq %3\n\t" + : "=d" (hi), + "=a" (lo) + : "%a" (multiplier), + "rm" (multiplicand) + : "cc" ); *product_hi = hi; return lo; #elif defined(__SIZEOF_INT128__) typedef unsigned __int128 uint128_t; uint128_t res = (uint128_t)multiplier * (uint128_t)multiplicand; - *product_hi = (uint64_t)(res >> 64); - return (uint64_t)res; + *product_hi = (uint64_t) (res >> 64); + return (uint64_t) res; #else - // multiplier = ab = a * 2^32 + b - // multiplicand = cd = c * 2^32 + d - // ab * cd = a * c * 2^64 + (a * d + b * c) * 2^32 + b * d - uint64_t a = hi_dword(multiplier); - uint64_t b = lo_dword(multiplier); - uint64_t c = hi_dword(multiplicand); - uint64_t d = lo_dword(multiplicand); - - uint64_t ac = a * c; - uint64_t ad = a * d; - uint64_t bc = b * c; - uint64_t bd = b * d; - - uint64_t adbc = ad + bc; - uint64_t adbc_carry = adbc < ad ? 1 : 0; - - // multiplier * multiplicand = product_hi * 2^64 + product_lo - uint64_t product_lo = bd + (adbc << 32); - uint64_t product_lo_carry = product_lo < bd ? 1 : 0; - *product_hi = ac + (adbc >> 32) + (adbc_carry << 32) + product_lo_carry; - assert(ac <= *product_hi); - - return product_lo; + // multiplier = ab = a * 2^32 + b + // multiplicand = cd = c * 2^32 + d + // ab * cd = a * c * 2^64 + (a * d + b * c) * 2^32 + b * d + uint64_t a = hi_dword(multiplier); + uint64_t b = lo_dword(multiplier); + uint64_t c = hi_dword(multiplicand); + uint64_t d = lo_dword(multiplicand); + + uint64_t ac = a * c; + uint64_t ad = a * d; + uint64_t bc = b * c; + uint64_t bd = b * d; + + uint64_t adbc = ad + bc; + uint64_t adbc_carry = adbc < ad ? 1 : 0; + + // multiplier * multiplicand = product_hi * 2^64 + product_lo + uint64_t product_lo = bd + (adbc << 32); + uint64_t product_lo_carry = product_lo < bd ? 1 : 0; + *product_hi = ac + (adbc >> 32) + (adbc_carry << 32) + product_lo_carry; + assert(ac <= *product_hi); + + return product_lo; #endif } -static inline uint64_t div_with_reminder(uint64_t dividend, uint32_t divisor, uint32_t *remainder) { - dividend |= ((uint64_t)*remainder) << 32; - *remainder = dividend % divisor; - return dividend / divisor; +static inline uint64_t div_with_reminder(uint64_t dividend, uint32_t divisor, uint32_t* remainder) { + dividend |= ((uint64_t)*remainder) << 32; + *remainder = dividend % divisor; + return dividend / divisor; } // Long division with 2^32 base -static inline uint32_t div128_32(uint64_t dividend_hi, - uint64_t dividend_lo, - uint32_t divisor, - uint64_t *quotient_hi, - uint64_t *quotient_lo) { - uint64_t dividend_dwords[4]; - uint32_t remainder = 0; - - dividend_dwords[3] = hi_dword(dividend_hi); - dividend_dwords[2] = lo_dword(dividend_hi); - dividend_dwords[1] = hi_dword(dividend_lo); - dividend_dwords[0] = lo_dword(dividend_lo); - - *quotient_hi = div_with_reminder(dividend_dwords[3], divisor, &remainder) << 32; - *quotient_hi |= div_with_reminder(dividend_dwords[2], divisor, &remainder); - *quotient_lo = div_with_reminder(dividend_dwords[1], divisor, &remainder) << 32; - *quotient_lo |= div_with_reminder(dividend_dwords[0], divisor, &remainder); - - return remainder; +static inline uint32_t div128_32(uint64_t dividend_hi, uint64_t dividend_lo, uint32_t divisor, uint64_t* quotient_hi, uint64_t* quotient_lo) { + uint64_t dividend_dwords[4]; + uint32_t remainder = 0; + + dividend_dwords[3] = hi_dword(dividend_hi); + dividend_dwords[2] = lo_dword(dividend_hi); + dividend_dwords[1] = hi_dword(dividend_lo); + dividend_dwords[0] = lo_dword(dividend_lo); + + *quotient_hi = div_with_reminder(dividend_dwords[3], divisor, &remainder) << 32; + *quotient_hi |= div_with_reminder(dividend_dwords[2], divisor, &remainder); + *quotient_lo = div_with_reminder(dividend_dwords[1], divisor, &remainder) << 32; + *quotient_lo |= div_with_reminder(dividend_dwords[0], divisor, &remainder); + + return remainder; } -#define IDENT32(x) ((uint32_t)(x)) +#define IDENT32(x) ((uint32_t) (x)) +#define IDENT64(x) ((uint64_t) (x)) + +#define SWAP32(x) ((((uint32_t) (x) & 0x000000ff) << 24) | \ + (((uint32_t) (x) & 0x0000ff00) << 8) | \ + (((uint32_t) (x) & 0x00ff0000) >> 8) | \ + (((uint32_t) (x) & 0xff000000) >> 24)) +#define SWAP64(x) ((((uint64_t) (x) & 0x00000000000000ff) << 56) | \ + (((uint64_t) (x) & 0x000000000000ff00) << 40) | \ + (((uint64_t) (x) & 0x0000000000ff0000) << 24) | \ + (((uint64_t) (x) & 0x00000000ff000000) << 8) | \ + (((uint64_t) (x) & 0x000000ff00000000) >> 8) | \ + (((uint64_t) (x) & 0x0000ff0000000000) >> 24) | \ + (((uint64_t) (x) & 0x00ff000000000000) >> 40) | \ + (((uint64_t) (x) & 0xff00000000000000) >> 56)) + +static inline uint32_t ident32(uint32_t x) { return x; } +static inline uint64_t ident64(uint64_t x) { return x; } + +static inline uint32_t swap32(uint32_t x) { + x = ((x & 0x00ff00ff) << 8) | ((x & 0xff00ff00) >> 8); + return (x << 16) | (x >> 16); +} +static inline uint64_t swap64(uint64_t x) { + x = ((x & 0x00ff00ff00ff00ff) << 8) | ((x & 0xff00ff00ff00ff00) >> 8); + x = ((x & 0x0000ffff0000ffff) << 16) | ((x & 0xffff0000ffff0000) >> 16); + return (x << 32) | (x >> 32); +} -#define SWAP32(x) \ - ((((uint32_t)(x)&0x000000ff) << 24) | (((uint32_t)(x)&0x0000ff00) << 8) | (((uint32_t)(x)&0x00ff0000) >> 8) | \ - (((uint32_t)(x)&0xff000000) >> 24)) +#if defined(__GNUC__) +#define UNUSED __attribute__((unused)) +#else +#define UNUSED +#endif +//inline void mem_inplace_ident(void *mem UNUSED, size_t n UNUSED) { } +#undef UNUSED + +//inline void mem_inplace_swap32(void *mem, size_t n) { +// size_t i; +// for (i = 0; i < n; i++) { +// ((uint32_t *) mem)[i] = swap32(((const uint32_t *) mem)[i]); +// } +//} +//inline void mem_inplace_swap64(void *mem, size_t n) { +// size_t i; +// for (i = 0; i < n; i++) { +// ((uint64_t *) mem)[i] = swap64(((const uint64_t *) mem)[i]); +// } +//} + +//inline void memcpy_ident32(void *dst, const void *src, size_t n) { +// memcpy(dst, src, 4 * n); +//} +//inline void memcpy_ident64(void *dst, const void *src, size_t n) { +// memcpy(dst, src, 8 * n); +//} +// +//inline void memcpy_swap32(void *dst, const void *src, size_t n) { +// size_t i; +// for (i = 0; i < n; i++) { +// ((uint32_t *) dst)[i] = swap32(((const uint32_t *) src)[i]); +// } +//} +//inline void memcpy_swap64(void *dst, const void *src, size_t n) { +// size_t i; +// for (i = 0; i < n; i++) { +// ((uint64_t *) dst)[i] = swap64(((const uint64_t *) src)[i]); +// } +//} #if !defined(BYTE_ORDER) || !defined(LITTLE_ENDIAN) || !defined(BIG_ENDIAN) -// static_assert(false, "BYTE_ORDER is undefined. Perhaps, GNU extensions are not enabled"); +//static_assert(false, "BYTE_ORDER is undefined. Perhaps, GNU extensions are not enabled"); #define LITTLE_ENDIAN 1234 #define BIG_ENDIAN 4321 #define BYTE_ORDER LITTLE_ENDIAN @@ -134,10 +207,40 @@ static inline uint32_t div128_32(uint64_t dividend_hi, #if BYTE_ORDER == LITTLE_ENDIAN #define SWAP32LE IDENT32 +#define SWAP32BE SWAP32 +#define swap32le ident32 +#define swap32be swap32 +#define mem_inplace_swap32le mem_inplace_ident +#define mem_inplace_swap32be mem_inplace_swap32 +#define memcpy_swap32le memcpy_ident32 +#define memcpy_swap32be memcpy_swap32 +#define SWAP64LE IDENT64 +#define SWAP64BE SWAP64 +#define swap64le ident64 +#define swap64be swap64 +#define mem_inplace_swap64le mem_inplace_ident +#define mem_inplace_swap64be mem_inplace_swap64 +#define memcpy_swap64le memcpy_ident64 +#define memcpy_swap64be memcpy_swap64 #endif #if BYTE_ORDER == BIG_ENDIAN +#define SWAP32BE IDENT32 #define SWAP32LE SWAP32 +#define swap32be ident32 +#define swap32le swap32 +#define mem_inplace_swap32be mem_inplace_ident +#define mem_inplace_swap32le mem_inplace_swap32 +#define memcpy_swap32be memcpy_ident32 +#define memcpy_swap32le memcpy_swap32 +#define SWAP64BE IDENT64 +#define SWAP64LE SWAP64 +#define swap64be ident64 +#define swap64le swap64 +#define mem_inplace_swap64be mem_inplace_ident +#define mem_inplace_swap64le mem_inplace_swap64 +#define memcpy_swap64be memcpy_ident64 +#define memcpy_swap64le memcpy_swap64 #endif #if defined(__cplusplus) diff --git a/src/crypto/jh/jh.c b/src/crypto/jh/jh.c old mode 100644 new mode 100755 diff --git a/src/crypto/jh/jh.h b/src/crypto/jh/jh.h old mode 100644 new mode 100755 diff --git a/src/crypto/keccak.c b/src/crypto/keccak.c new file mode 100644 index 00000000..23deec61 --- /dev/null +++ b/src/crypto/keccak.c @@ -0,0 +1,112 @@ +// keccak.c +// 19-Nov-11 Markku-Juhani O. Saarinen +// A baseline Keccak (3rd round) implementation. + +#include "hash-impl.h" +#include "keccak.h" + +const uint64_t keccakf_rndc[24] = +{ + 0x0000000000000001, 0x0000000000008082, 0x800000000000808a, + 0x8000000080008000, 0x000000000000808b, 0x0000000080000001, + 0x8000000080008081, 0x8000000000008009, 0x000000000000008a, + 0x0000000000000088, 0x0000000080008009, 0x000000008000000a, + 0x000000008000808b, 0x800000000000008b, 0x8000000000008089, + 0x8000000000008003, 0x8000000000008002, 0x8000000000000080, + 0x000000000000800a, 0x800000008000000a, 0x8000000080008081, + 0x8000000000008080, 0x0000000080000001, 0x8000000080008008 +}; + +const int keccakf_rotc[24] = +{ + 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14, + 27, 41, 56, 8, 25, 43, 62, 18, 39, 61, 20, 44 +}; + +const int keccakf_piln[24] = +{ + 10, 7, 11, 17, 18, 3, 5, 16, 8, 21, 24, 4, + 15, 23, 19, 13, 12, 2, 20, 14, 22, 9, 6, 1 +}; + +// update the state with given number of rounds + +void keccakf(uint64_t st[25], int rounds) +{ + int i, j, round; + uint64_t t, bc[5]; + + for (round = 0; round < rounds; round++) { + + // Theta + for (i = 0; i < 5; i++) + bc[i] = st[i] ^ st[i + 5] ^ st[i + 10] ^ st[i + 15] ^ st[i + 20]; + + for (i = 0; i < 5; i++) { + t = bc[(i + 4) % 5] ^ ROTL64(bc[(i + 1) % 5], 1); + for (j = 0; j < 25; j += 5) + st[j + i] ^= t; + } + + // Rho Pi + t = st[1]; + for (i = 0; i < 24; i++) { + j = keccakf_piln[i]; + bc[0] = st[j]; + st[j] = ROTL64(t, keccakf_rotc[i]); + t = bc[0]; + } + + // Chi + for (j = 0; j < 25; j += 5) { + for (i = 0; i < 5; i++) + bc[i] = st[j + i]; + for (i = 0; i < 5; i++) + st[j + i] ^= (~bc[(i + 1) % 5]) & bc[(i + 2) % 5]; + } + + // Iota + st[0] ^= keccakf_rndc[round]; + } +} + +// compute a keccak hash (md) of given byte length from "in" +typedef uint64_t state_t[25]; + +int keccak(const uint8_t *in, int inlen, uint8_t *md, int mdlen) +{ + state_t st; + uint8_t temp[144]; + int i, rsiz, rsizw; + + rsiz = sizeof(state_t) == mdlen ? HASH_DATA_AREA : 200 - 2 * mdlen; + rsizw = rsiz / 8; + + memset(st, 0, sizeof(st)); + + for ( ; inlen >= rsiz; inlen -= rsiz, in += rsiz) { + for (i = 0; i < rsizw; i++) + st[i] ^= ((uint64_t *) in)[i]; + keccakf(st, KECCAK_ROUNDS); + } + + // last block and padding + memcpy(temp, in, inlen); + temp[inlen++] = 1; + memset(temp + inlen, 0, rsiz - inlen); + temp[rsiz - 1] |= 0x80; + + for (i = 0; i < rsizw; i++) + st[i] ^= ((uint64_t *) temp)[i]; + + keccakf(st, KECCAK_ROUNDS); + + memcpy(md, st, mdlen); + + return 0; +} + +void keccak1600(const uint8_t *in, int inlen, uint8_t *md) +{ + keccak(in, inlen, md, sizeof(state_t)); +} diff --git a/src/crypto/keccak.h b/src/crypto/keccak.h new file mode 100644 index 00000000..3dd01dfa --- /dev/null +++ b/src/crypto/keccak.h @@ -0,0 +1,31 @@ +// keccak.h +// 19-Nov-11 Markku-Juhani O. Saarinen +#pragma once + +#include +#include + +#if defined(__cplusplus) +extern "C" { +#endif + +#ifndef KECCAK_ROUNDS +#define KECCAK_ROUNDS 24 +#endif + +#ifndef ROTL64 +#define ROTL64(x, y) (((x) << (y)) | ((x) >> (64 - (y)))) +#endif + +// compute a keccak hash (md) of given byte length from "in" +int keccak(const uint8_t *in, int inlen, uint8_t *md, int mdlen); + +// update the state +void keccakf(uint64_t st[25], int norounds); + +void keccak1600(const uint8_t *in, int inlen, uint8_t *md); + +#if defined(__cplusplus) +} +#endif + diff --git a/src/crypto/keccak/Keccak-readable-and-compact.c b/src/crypto/keccak/Keccak-readable-and-compact.c old mode 100644 new mode 100755 diff --git a/src/crypto/keccak/README.md b/src/crypto/keccak/README.md old mode 100644 new mode 100755 diff --git a/src/crypto/oaes/aesb.h b/src/crypto/oaes/aesb.h old mode 100644 new mode 100755 diff --git a/src/crypto/oaes/oaes_config.h b/src/crypto/oaes/oaes_config.h old mode 100644 new mode 100755 diff --git a/src/crypto/oaes/oaes_lib.c b/src/crypto/oaes/oaes_lib.c old mode 100644 new mode 100755 diff --git a/src/crypto/oaes/oaes_lib.h b/src/crypto/oaes/oaes_lib.h old mode 100644 new mode 100755 diff --git a/src/crypto/random.c b/src/crypto/random.c old mode 100644 new mode 100755 diff --git a/src/crypto/random.h b/src/crypto/random.h old mode 100644 new mode 100755 diff --git a/src/crypto/skein/skein.c b/src/crypto/skein/skein.c old mode 100644 new mode 100755 diff --git a/src/crypto/skein/skein.h b/src/crypto/skein/skein.h old mode 100644 new mode 100755 diff --git a/src/crypto/skein/skein_port.h b/src/crypto/skein/skein_port.h old mode 100644 new mode 100755 diff --git a/src/crypto/slow-hash.c b/src/crypto/slow-hash.c new file mode 100644 index 00000000..160b3091 --- /dev/null +++ b/src/crypto/slow-hash.c @@ -0,0 +1,1598 @@ +// Copyright (c) 2014-2018, The Monero Project +// +// 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. +// +// 3. Neither the name of the copyright holder 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 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. +// +// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers + +#include +#include +#include +#include +#include +#ifndef _MSC_VER +#include +#endif // (_MSC_VER) + +#include "int-util.h" +#include "hash-ops.h" +#include "oaes/oaes_lib.h" +#include "variant2_int_sqrt.h" +#include "hash-impl.h" + +#include "oaes/aesb.h" + +#define MEMORY (1 << 21) // 2MB scratchpad +#define ITER 0x80000 * 2 //(1 << 20) +#define ITER_ZLX 0x60000 * 2 +#define AES_BLOCK_SIZE 16 +#define AES_KEY_SIZE 32 +#define INIT_SIZE_BLK 8 +#define INIT_SIZE_BYTE (INIT_SIZE_BLK * AES_BLOCK_SIZE) + +//extern int aesb_single_round(const uint8_t *in, uint8_t*out, const uint8_t *expandedKey); +//extern int aesb_pseudo_round(const uint8_t *in, uint8_t *out, const uint8_t *expandedKey); + +#define VARIANT_ZLX() \ + uint32_t iterations = ITER; \ + do if (variant == 3) \ + { \ + iterations = ITER_ZLX; \ + } while(0) + +#define VARIANT1_1(p) \ + do if (variant == 1) \ + { \ + const uint8_t tmp = ((const uint8_t*)(p))[11]; \ + static const uint32_t table = 0x75310; \ + const uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; \ + ((uint8_t*)(p))[11] = tmp ^ ((table >> index) & 0x30); \ + } while(0) + +#define VARIANT1_2(p) \ + do if (variant == 1) \ + { \ + xor64(p, tweak1_2); \ + } while(0) + +#define VARIANT1_CHECK() \ + do if (length < 43) \ + { \ + fprintf(stderr, "Cryptonight variant 1 needs at least 43 bytes of data"); \ + _exit(1); \ + } while(0) + +#define NONCE_POINTER (((const uint8_t*)data)+35) + +#define VARIANT1_PORTABLE_INIT() \ + uint8_t tweak1_2[8]; \ + do if (variant == 1) \ + { \ + VARIANT1_CHECK(); \ + memcpy(&tweak1_2, &state.hs.b[192], sizeof(tweak1_2)); \ + xor64(tweak1_2, NONCE_POINTER); \ + } while(0) + +#define VARIANT1_INIT64() \ + if (variant == 1) \ + { \ + VARIANT1_CHECK(); \ + } \ + const uint64_t tweak1_2 = (variant == 1) ? (state.hs.w[24] ^ (*((const uint64_t*)NONCE_POINTER))) : 0 + +#define VARIANT2_INIT64() \ + uint64_t division_result = 0; \ + uint64_t sqrt_result = 0; \ + do if (variant >= 2) \ + { \ + U64(b)[2] = state.hs.w[8] ^ state.hs.w[10]; \ + U64(b)[3] = state.hs.w[9] ^ state.hs.w[11]; \ + division_result = state.hs.w[12]; \ + sqrt_result = state.hs.w[13]; \ + } while (0) + +#define VARIANT2_PORTABLE_INIT() \ + uint64_t division_result = 0; \ + uint64_t sqrt_result = 0; \ + do if (variant >= 2) \ + { \ + memcpy(b + AES_BLOCK_SIZE, state.hs.b + 64, AES_BLOCK_SIZE); \ + xor64(b + AES_BLOCK_SIZE, state.hs.b + 80); \ + xor64(b + AES_BLOCK_SIZE + 8, state.hs.b + 88); \ + division_result = SWAP64LE(state.hs.w[12]); \ + sqrt_result = SWAP64LE(state.hs.w[13]); \ + } while (0) + +#define VARIANT2_SHUFFLE_ADD_SSE2(base_ptr, offset) \ + do if (variant >= 2) \ + { \ + const __m128i chunk1 = _mm_load_si128((__m128i *)((base_ptr) + ((offset) ^ 0x10))); \ + const __m128i chunk2 = _mm_load_si128((__m128i *)((base_ptr) + ((offset) ^ 0x20))); \ + const __m128i chunk3 = _mm_load_si128((__m128i *)((base_ptr) + ((offset) ^ 0x30))); \ + _mm_store_si128((__m128i *)((base_ptr) + ((offset) ^ 0x10)), _mm_add_epi64(chunk3, _b1)); \ + _mm_store_si128((__m128i *)((base_ptr) + ((offset) ^ 0x20)), _mm_add_epi64(chunk1, _b)); \ + _mm_store_si128((__m128i *)((base_ptr) + ((offset) ^ 0x30)), _mm_add_epi64(chunk2, _a)); \ + } while (0) + +#define VARIANT2_SHUFFLE_ADD_NEON(base_ptr, offset) \ + do if (variant >= 2) \ + { \ + const uint64x2_t chunk1 = vld1q_u64(U64((base_ptr) + ((offset) ^ 0x10))); \ + const uint64x2_t chunk2 = vld1q_u64(U64((base_ptr) + ((offset) ^ 0x20))); \ + const uint64x2_t chunk3 = vld1q_u64(U64((base_ptr) + ((offset) ^ 0x30))); \ + vst1q_u64(U64((base_ptr) + ((offset) ^ 0x10)), vaddq_u64(chunk3, vreinterpretq_u64_u8(_b1))); \ + vst1q_u64(U64((base_ptr) + ((offset) ^ 0x20)), vaddq_u64(chunk1, vreinterpretq_u64_u8(_b))); \ + vst1q_u64(U64((base_ptr) + ((offset) ^ 0x30)), vaddq_u64(chunk2, vreinterpretq_u64_u8(_a))); \ + } while (0) + +#define VARIANT2_PORTABLE_SHUFFLE_ADD(base_ptr, offset) \ + do if (variant >= 2) \ + { \ + uint64_t* chunk1 = U64((base_ptr) + ((offset) ^ 0x10)); \ + uint64_t* chunk2 = U64((base_ptr) + ((offset) ^ 0x20)); \ + uint64_t* chunk3 = U64((base_ptr) + ((offset) ^ 0x30)); \ + \ + const uint64_t chunk1_old[2] = { chunk1[0], chunk1[1] }; \ + \ + uint64_t b1[2]; \ + memcpy_swap64le(b1, b + 16, 2); \ + chunk1[0] = SWAP64LE(SWAP64LE(chunk3[0]) + b1[0]); \ + chunk1[1] = SWAP64LE(SWAP64LE(chunk3[1]) + b1[1]); \ + \ + uint64_t a0[2]; \ + memcpy_swap64le(a0, a, 2); \ + chunk3[0] = SWAP64LE(SWAP64LE(chunk2[0]) + a0[0]); \ + chunk3[1] = SWAP64LE(SWAP64LE(chunk2[1]) + a0[1]); \ + \ + uint64_t b0[2]; \ + memcpy_swap64le(b0, b, 2); \ + chunk2[0] = SWAP64LE(SWAP64LE(chunk1_old[0]) + b0[0]); \ + chunk2[1] = SWAP64LE(SWAP64LE(chunk1_old[1]) + b0[1]); \ + } while (0) + +#define VARIANT2_INTEGER_MATH_DIVISION_STEP(b, ptr) \ + uint64_t tmpx = division_result ^ (sqrt_result << 32); \ + ((uint64_t*)(b))[0] ^= SWAP64LE(tmpx); \ + { \ + const uint64_t dividend = SWAP64LE(((uint64_t*)(ptr))[1]); \ + const uint32_t divisor = (SWAP64LE(((uint64_t*)(ptr))[0]) + (uint32_t)(sqrt_result << 1)) | 0x80000001UL; \ + division_result = ((uint32_t)(dividend / divisor)) + \ + (((uint64_t)(dividend % divisor)) << 32); \ + } \ + const uint64_t sqrt_input = SWAP64LE(((uint64_t*)(ptr))[0]) + division_result + +#define VARIANT2_INTEGER_MATH_SSE2(b, ptr) \ + do if (variant >= 2) \ + { \ + VARIANT2_INTEGER_MATH_DIVISION_STEP(b, ptr); \ + VARIANT2_INTEGER_MATH_SQRT_STEP_SSE2(); \ + VARIANT2_INTEGER_MATH_SQRT_FIXUP(sqrt_result); \ + } while(0) + +#if defined DBL_MANT_DIG && (DBL_MANT_DIG >= 50) + // double precision floating point type has enough bits of precision on current platform + #define VARIANT2_PORTABLE_INTEGER_MATH(b, ptr) \ + do if (variant >= 2) \ + { \ + VARIANT2_INTEGER_MATH_DIVISION_STEP(b, ptr); \ + VARIANT2_INTEGER_MATH_SQRT_STEP_FP64(); \ + VARIANT2_INTEGER_MATH_SQRT_FIXUP(sqrt_result); \ + } while (0) +#else + // double precision floating point type is not good enough on current platform + // fall back to the reference code (integer only) + #define VARIANT2_PORTABLE_INTEGER_MATH(b, ptr) \ + do if (variant >= 2) \ + { \ + VARIANT2_INTEGER_MATH_DIVISION_STEP(b, ptr); \ + VARIANT2_INTEGER_MATH_SQRT_STEP_REF(); \ + } while (0) +#endif + +#define VARIANT2_2_PORTABLE() \ + if (variant >= 2) { \ + xor_blocks(long_state + (j ^ 0x10), d); \ + xor_blocks(d, long_state + (j ^ 0x20)); \ + } + +#define VARIANT2_2() \ + do if (variant >= 2) \ + { \ + *U64(hp_state + (j ^ 0x10)) ^= SWAP64LE(hi); \ + *(U64(hp_state + (j ^ 0x10)) + 1) ^= SWAP64LE(lo); \ + hi ^= SWAP64LE(*U64(hp_state + (j ^ 0x20))); \ + lo ^= SWAP64LE(*(U64(hp_state + (j ^ 0x20)) + 1)); \ + } while (0) + + +#if !defined NO_AES && (defined(__x86_64__) || (defined(_MSC_VER) && defined(_WIN64))) +// Optimised code below, uses x86-specific intrinsics, SSE2, AES-NI +// Fall back to more portable code is down at the bottom + +#include + +#if defined(_MSC_VER) +#include +#include +#define STATIC +#define INLINE __inline +#if !defined(RDATA_ALIGN16) +#define RDATA_ALIGN16 __declspec(align(16)) +#endif +#elif defined(__MINGW32__) +#include +#include +#define STATIC static +#define INLINE inline +#if !defined(RDATA_ALIGN16) +#define RDATA_ALIGN16 __attribute__ ((aligned(16))) +#endif +#else +#include +#include +#define STATIC static +#define INLINE inline +#if !defined(RDATA_ALIGN16) +#define RDATA_ALIGN16 __attribute__ ((aligned(16))) +#endif +#endif + +#if defined(__INTEL_COMPILER) +#define ASM __asm__ +#elif !defined(_MSC_VER) +#define ASM __asm__ +#else +#define ASM __asm +#endif + +#define TOTALBLOCKS (MEMORY / AES_BLOCK_SIZE) + +#define U64(x) ((uint64_t *) (x)) +#define R128(x) ((__m128i *) (x)) + +#define state_index(x) (((*((uint64_t *)x) >> 4) & (TOTALBLOCKS - 1)) << 4) +#if defined(_MSC_VER) +#if !defined(_WIN64) +#define __mul() lo = mul128(c[0], b[0], &hi); +#else +#define __mul() lo = _umul128(c[0], b[0], &hi); +#endif +#else +#if defined(__x86_64__) +#define __mul() ASM("mulq %3\n\t" : "=d"(hi), "=a"(lo) : "%a" (c[0]), "rm" (b[0]) : "cc"); +#else +#define __mul() lo = mul128(c[0], b[0], &hi); +#endif +#endif + +#define pre_aes() \ + j = state_index(a); \ + _c = _mm_load_si128(R128(&hp_state[j])); \ + _a = _mm_load_si128(R128(a)); \ + +/* + * An SSE-optimized implementation of the second half of CryptoNight step 3. + * After using AES to mix a scratchpad value into _c (done by the caller), + * this macro xors it with _b and stores the result back to the same index (j) that it + * loaded the scratchpad value from. It then performs a second random memory + * read/write from the scratchpad, but this time mixes the values using a 64 + * bit multiply. + * This code is based upon an optimized implementation by dga. + */ +#define post_aes() \ + VARIANT2_SHUFFLE_ADD_SSE2(hp_state, j); \ + _mm_store_si128(R128(c), _c); \ + _mm_store_si128(R128(&hp_state[j]), _mm_xor_si128(_b, _c)); \ + VARIANT1_1(&hp_state[j]); \ + j = state_index(c); \ + p = U64(&hp_state[j]); \ + b[0] = p[0]; b[1] = p[1]; \ + VARIANT2_INTEGER_MATH_SSE2(b, c); \ + __mul(); \ + VARIANT2_2(); \ + VARIANT2_SHUFFLE_ADD_SSE2(hp_state, j); \ + a[0] += hi; a[1] += lo; \ + p = U64(&hp_state[j]); \ + p[0] = a[0]; p[1] = a[1]; \ + a[0] ^= b[0]; a[1] ^= b[1]; \ + VARIANT1_2(p + 1); \ + _b1 = _b; \ + _b = _c; \ + +#if defined(_MSC_VER) +#define THREADV __declspec(thread) +#else +#define THREADV __thread +#endif + +#pragma pack(push, 1) +union cn_slow_hash_state +{ + union hash_state hs; + struct + { + uint8_t k[64]; + uint8_t init[INIT_SIZE_BYTE]; + }; +}; +#pragma pack(pop) + +THREADV uint8_t *hp_state = NULL; +THREADV int hp_allocated = 0; + +#if defined(_MSC_VER) +#define cpuid(info,x) __cpuidex(info,x,0) +#else +void cpuid(int CPUInfo[4], int InfoType) +{ + ASM __volatile__ + ( + "cpuid": + "=a" (CPUInfo[0]), + "=b" (CPUInfo[1]), + "=c" (CPUInfo[2]), + "=d" (CPUInfo[3]) : + "a" (InfoType), "c" (0) + ); +} +#endif + +/** + * @brief a = (a xor b), where a and b point to 128 bit values + */ + +STATIC INLINE void xor_blocks(uint8_t *a, const uint8_t *b) +{ + U64(a)[0] ^= U64(b)[0]; + U64(a)[1] ^= U64(b)[1]; +} + +STATIC INLINE void xor64(uint64_t *a, const uint64_t b) +{ + *a ^= b; +} + +/** + * @brief uses cpuid to determine if the CPU supports the AES instructions + * @return true if the CPU supports AES, false otherwise + */ + +STATIC INLINE int force_software_aes(void) +{ + static int use = -1; + + if (use != -1) + return use; + + const char *env = getenv("MONERO_USE_SOFTWARE_AES"); + if (!env) { + use = 0; + } + else if (!strcmp(env, "0") || !strcmp(env, "no")) { + use = 0; + } + else { + use = 1; + } + return use; +} + +STATIC INLINE int check_aes_hw(void) +{ + int cpuid_results[4]; + static int supported = -1; + + if(supported >= 0) + return supported; + + cpuid(cpuid_results,1); + return supported = cpuid_results[2] & (1 << 25); +} + +STATIC INLINE void aes_256_assist1(__m128i* t1, __m128i * t2) +{ + __m128i t4; + *t2 = _mm_shuffle_epi32(*t2, 0xff); + t4 = _mm_slli_si128(*t1, 0x04); + *t1 = _mm_xor_si128(*t1, t4); + t4 = _mm_slli_si128(t4, 0x04); + *t1 = _mm_xor_si128(*t1, t4); + t4 = _mm_slli_si128(t4, 0x04); + *t1 = _mm_xor_si128(*t1, t4); + *t1 = _mm_xor_si128(*t1, *t2); +} + +STATIC INLINE void aes_256_assist2(__m128i* t1, __m128i * t3) +{ + __m128i t2, t4; + t4 = _mm_aeskeygenassist_si128(*t1, 0x00); + t2 = _mm_shuffle_epi32(t4, 0xaa); + t4 = _mm_slli_si128(*t3, 0x04); + *t3 = _mm_xor_si128(*t3, t4); + t4 = _mm_slli_si128(t4, 0x04); + *t3 = _mm_xor_si128(*t3, t4); + t4 = _mm_slli_si128(t4, 0x04); + *t3 = _mm_xor_si128(*t3, t4); + *t3 = _mm_xor_si128(*t3, t2); +} + +/** + * @brief expands 'key' into a form it can be used for AES encryption. + * + * This is an SSE-optimized implementation of AES key schedule generation. It + * expands the key into multiple round keys, each of which is used in one round + * of the AES encryption used to fill (and later, extract randomness from) + * the large 2MB buffer. Note that CryptoNight does not use a completely + * standard AES encryption for its buffer expansion, so do not copy this + * function outside of Monero without caution! This version uses the hardware + * AESKEYGENASSIST instruction to speed key generation, and thus requires + * CPU AES support. + * For more information about these functions, see page 19 of Intel's AES instructions + * white paper: + * https://www.intel.com/content/dam/doc/white-paper/advanced-encryption-standard-new-instructions-set-paper.pdf + * + * @param key the input 128 bit key + * @param expandedKey An output buffer to hold the generated key schedule + */ + +STATIC INLINE void aes_expand_key(const uint8_t *key, uint8_t *expandedKey) +{ + __m128i *ek = R128(expandedKey); + __m128i t1, t2, t3; + + t1 = _mm_loadu_si128(R128(key)); + t3 = _mm_loadu_si128(R128(key + 16)); + + ek[0] = t1; + ek[1] = t3; + + t2 = _mm_aeskeygenassist_si128(t3, 0x01); + aes_256_assist1(&t1, &t2); + ek[2] = t1; + aes_256_assist2(&t1, &t3); + ek[3] = t3; + + t2 = _mm_aeskeygenassist_si128(t3, 0x02); + aes_256_assist1(&t1, &t2); + ek[4] = t1; + aes_256_assist2(&t1, &t3); + ek[5] = t3; + + t2 = _mm_aeskeygenassist_si128(t3, 0x04); + aes_256_assist1(&t1, &t2); + ek[6] = t1; + aes_256_assist2(&t1, &t3); + ek[7] = t3; + + t2 = _mm_aeskeygenassist_si128(t3, 0x08); + aes_256_assist1(&t1, &t2); + ek[8] = t1; + aes_256_assist2(&t1, &t3); + ek[9] = t3; + + t2 = _mm_aeskeygenassist_si128(t3, 0x10); + aes_256_assist1(&t1, &t2); + ek[10] = t1; +} + +/** + * @brief a "pseudo" round of AES (similar to but slightly different from normal AES encryption) + * + * To fill its 2MB scratch buffer, CryptoNight uses a nonstandard implementation + * of AES encryption: It applies 10 rounds of the basic AES encryption operation + * to an input 128 bit chunk of data . Unlike normal AES, however, this is + * all it does; it does not perform the initial AddRoundKey step (this is done + * in subsequent steps by aesenc_si128), and it does not use the simpler final round. + * Hence, this is a "pseudo" round - though the function actually implements 10 rounds together. + * + * Note that unlike aesb_pseudo_round, this function works on multiple data chunks. + * + * @param in a pointer to nblocks * 128 bits of data to be encrypted + * @param out a pointer to an nblocks * 128 bit buffer where the output will be stored + * @param expandedKey the expanded AES key + * @param nblocks the number of 128 blocks of data to be encrypted + */ + +STATIC INLINE void aes_pseudo_round(const uint8_t *in, uint8_t *out, + const uint8_t *expandedKey, int nblocks) +{ + __m128i *k = R128(expandedKey); + __m128i d; + int i; + + for(i = 0; i < nblocks; i++) + { + d = _mm_loadu_si128(R128(in + i * AES_BLOCK_SIZE)); + d = _mm_aesenc_si128(d, *R128(&k[0])); + d = _mm_aesenc_si128(d, *R128(&k[1])); + d = _mm_aesenc_si128(d, *R128(&k[2])); + d = _mm_aesenc_si128(d, *R128(&k[3])); + d = _mm_aesenc_si128(d, *R128(&k[4])); + d = _mm_aesenc_si128(d, *R128(&k[5])); + d = _mm_aesenc_si128(d, *R128(&k[6])); + d = _mm_aesenc_si128(d, *R128(&k[7])); + d = _mm_aesenc_si128(d, *R128(&k[8])); + d = _mm_aesenc_si128(d, *R128(&k[9])); + _mm_storeu_si128((R128(out + i * AES_BLOCK_SIZE)), d); + } +} + +/** + * @brief aes_pseudo_round that loads data from *in and xors it with *xor first + * + * This function performs the same operations as aes_pseudo_round, but before + * performing the encryption of each 128 bit block from , it xors + * it with the corresponding block from . + * + * @param in a pointer to nblocks * 128 bits of data to be encrypted + * @param out a pointer to an nblocks * 128 bit buffer where the output will be stored + * @param expandedKey the expanded AES key + * @param xor a pointer to an nblocks * 128 bit buffer that is xored into in before encryption (in is left unmodified) + * @param nblocks the number of 128 blocks of data to be encrypted + */ + +STATIC INLINE void aes_pseudo_round_xor(const uint8_t *in, uint8_t *out, + const uint8_t *expandedKey, const uint8_t *xor, int nblocks) +{ + __m128i *k = R128(expandedKey); + __m128i *x = R128(xor); + __m128i d; + int i; + + for(i = 0; i < nblocks; i++) + { + d = _mm_loadu_si128(R128(in + i * AES_BLOCK_SIZE)); + d = _mm_xor_si128(d, *R128(x++)); + d = _mm_aesenc_si128(d, *R128(&k[0])); + d = _mm_aesenc_si128(d, *R128(&k[1])); + d = _mm_aesenc_si128(d, *R128(&k[2])); + d = _mm_aesenc_si128(d, *R128(&k[3])); + d = _mm_aesenc_si128(d, *R128(&k[4])); + d = _mm_aesenc_si128(d, *R128(&k[5])); + d = _mm_aesenc_si128(d, *R128(&k[6])); + d = _mm_aesenc_si128(d, *R128(&k[7])); + d = _mm_aesenc_si128(d, *R128(&k[8])); + d = _mm_aesenc_si128(d, *R128(&k[9])); + _mm_storeu_si128((R128(out + i * AES_BLOCK_SIZE)), d); + } +} + +#if defined(_MSC_VER) || defined(__MINGW32__) +BOOL SetLockPagesPrivilege(HANDLE hProcess, BOOL bEnable) +{ + struct + { + DWORD count; + LUID_AND_ATTRIBUTES privilege[1]; + } info; + + HANDLE token; + if(!OpenProcessToken(hProcess, TOKEN_ADJUST_PRIVILEGES, &token)) + return FALSE; + + info.count = 1; + info.privilege[0].Attributes = bEnable ? SE_PRIVILEGE_ENABLED : 0; + + if(!LookupPrivilegeValue(NULL, SE_LOCK_MEMORY_NAME, &(info.privilege[0].Luid))) + return FALSE; + + if(!AdjustTokenPrivileges(token, FALSE, (PTOKEN_PRIVILEGES) &info, 0, NULL, NULL)) + return FALSE; + + if (GetLastError() != ERROR_SUCCESS) + return FALSE; + + CloseHandle(token); + + return TRUE; + +} +#endif + +/** + * @brief allocate the 2MB scratch buffer using OS support for huge pages, if available + * + * This function tries to allocate the 2MB scratch buffer using a single + * 2MB "huge page" (instead of the usual 4KB page sizes) to reduce TLB misses + * during the random accesses to the scratch buffer. This is one of the + * important speed optimizations needed to make CryptoNight faster. + * + * No parameters. Updates a thread-local pointer, hp_state, to point to + * the allocated buffer. + */ + +void slow_hash_allocate_state(void) +{ + if(hp_state != NULL) + return; + +#if defined(_MSC_VER) || defined(__MINGW32__) + SetLockPagesPrivilege(GetCurrentProcess(), TRUE); + hp_state = (uint8_t *) VirtualAlloc(hp_state, MEMORY, MEM_LARGE_PAGES | + MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); +#else +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || \ + defined(__DragonFly__) || defined(__NetBSD__) + hp_state = mmap(0, MEMORY, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANON, 0, 0); +#else + hp_state = mmap(0, MEMORY, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, 0, 0); +#endif + if(hp_state == MAP_FAILED) + hp_state = NULL; +#endif + hp_allocated = 1; + if(hp_state == NULL) + { + hp_allocated = 0; + hp_state = (uint8_t *) malloc(MEMORY); + } +} + +/** + *@brief frees the state allocated by slow_hash_allocate_state + */ + +void slow_hash_free_state(void) +{ + if(hp_state == NULL) + return; + + if(!hp_allocated) + free(hp_state); + else + { +#if defined(_MSC_VER) || defined(__MINGW32__) + VirtualFree(hp_state, 0, MEM_RELEASE); +#else + munmap(hp_state, MEMORY); +#endif + } + + hp_state = NULL; + hp_allocated = 0; +} + +/** + * @brief the hash function implementing CryptoNight, used for the Monero proof-of-work + * + * Computes the hash of (which consists of bytes), returning the + * hash in . The CryptoNight hash operates by first using Keccak 1600, + * the 1600 bit variant of the Keccak hash used in SHA-3, to create a 200 byte + * buffer of pseudorandom data by hashing the supplied data. It then uses this + * random data to fill a large 2MB buffer with pseudorandom data by iteratively + * encrypting it using 10 rounds of AES per entry. After this initialization, + * it executes 524,288 rounds of mixing through the random 2MB buffer using + * AES (typically provided in hardware on modern CPUs) and a 64 bit multiply. + * Finally, it re-mixes this large buffer back into + * the 200 byte "text" buffer, and then hashes this buffer using one of four + * pseudorandomly selected hash functions (Blake, Groestl, JH, or Skein) + * to populate the output. + * + * The 2MB buffer and choice of functions for mixing are designed to make the + * algorithm "CPU-friendly" (and thus, reduce the advantage of GPU, FPGA, + * or ASIC-based implementations): the functions used are fast on modern + * CPUs, and the 2MB size matches the typical amount of L3 cache available per + * core on 2013-era CPUs. When available, this implementation will use hardware + * AES support on x86 CPUs. + * + * A diagram of the inner loop of this function can be found at + * https://www.cs.cmu.edu/~dga/crypto/xmr/cryptonight.png + * + * @param data the data to hash + * @param length the length in bytes of the data + * @param hash a pointer to a buffer in which the final 256 bit hash will be stored + */ +void cn_slow_hash(const void *data, size_t length, unsigned char *hash, int variant, int prehashed) +{ + RDATA_ALIGN16 uint8_t expandedKey[240]; /* These buffers are aligned to use later with SSE functions */ + + uint8_t text[INIT_SIZE_BYTE]; + RDATA_ALIGN16 uint64_t a[2]; + RDATA_ALIGN16 uint64_t b[4]; + RDATA_ALIGN16 uint64_t c[2]; + union cn_slow_hash_state state; + __m128i _a, _b, _b1, _c; + uint64_t hi, lo; + + size_t i, j; + uint64_t *p = NULL; + oaes_ctx *aes_ctx = NULL; + int useAes = !force_software_aes() && check_aes_hw(); + + static void (*const extra_hashes[4])(const void *, size_t, unsigned char *) = + { + hash_extra_blake, hash_extra_groestl, hash_extra_jh, hash_extra_skein + }; + + // this isn't supposed to happen, but guard against it for now. + if(hp_state == NULL) + slow_hash_allocate_state(); + + /* CryptoNight Step 1: Use Keccak1600 to initialize the 'state' (and 'text') buffers from the data. */ + if (prehashed) { + memcpy(&state.hs, data, length); + } else { + hash_process(&state.hs, data, length); + } + memcpy(text, state.init, INIT_SIZE_BYTE); + + VARIANT1_INIT64(); + VARIANT2_INIT64(); + + /* CryptoNight Step 2: Iteratively encrypt the results from Keccak to fill + * the 2MB large random access buffer. + */ + + if(useAes) + { + aes_expand_key(state.hs.b, expandedKey); + for(i = 0; i < MEMORY / INIT_SIZE_BYTE; i++) + { + aes_pseudo_round(text, text, expandedKey, INIT_SIZE_BLK); + memcpy(&hp_state[i * INIT_SIZE_BYTE], text, INIT_SIZE_BYTE); + } + } + else + { + aes_ctx = (oaes_ctx *) oaes_alloc(); + oaes_key_import_data(aes_ctx, state.hs.b, AES_KEY_SIZE); + for(i = 0; i < MEMORY / INIT_SIZE_BYTE; i++) + { + for(j = 0; j < INIT_SIZE_BLK; j++) + aesb_pseudo_round(&text[AES_BLOCK_SIZE * j], &text[AES_BLOCK_SIZE * j], aes_ctx->key->exp_data); + + memcpy(&hp_state[i * INIT_SIZE_BYTE], text, INIT_SIZE_BYTE); + } + } + + U64(a)[0] = U64(&state.k[0])[0] ^ U64(&state.k[32])[0]; + U64(a)[1] = U64(&state.k[0])[1] ^ U64(&state.k[32])[1]; + U64(b)[0] = U64(&state.k[16])[0] ^ U64(&state.k[48])[0]; + U64(b)[1] = U64(&state.k[16])[1] ^ U64(&state.k[48])[1]; + + /* CryptoNight Step 3: Bounce randomly 1,048,576 times (1<<20) through the mixing buffer, + * using 524,288 iterations of the following mixing function. Each execution + * performs two reads and writes from the mixing buffer. + */ + + _b = _mm_load_si128(R128(b)); + _b1 = _mm_load_si128(R128(b) + 1); + // Two independent versions, one with AES, one without, to ensure that + // the useAes test is only performed once, not every iteration. + VARIANT_ZLX(); + if(useAes) + { + for(i = 0; i < iterations / 2; i++) + { + pre_aes(); + _c = _mm_aesenc_si128(_c, _a); + post_aes(); + } + } + else + { + for(i = 0; i < iterations / 2; i++) + { + pre_aes(); + aesb_single_round((uint8_t *) &_c, (uint8_t *) &_c, (uint8_t *) &_a); + post_aes(); + } + } + + /* CryptoNight Step 4: Sequentially pass through the mixing buffer and use 10 rounds + * of AES encryption to mix the random data back into the 'text' buffer. 'text' + * was originally created with the output of Keccak1600. */ + + memcpy(text, state.init, INIT_SIZE_BYTE); + if(useAes) + { + aes_expand_key(&state.hs.b[32], expandedKey); + for(i = 0; i < MEMORY / INIT_SIZE_BYTE; i++) + { + // add the xor to the pseudo round + aes_pseudo_round_xor(text, text, expandedKey, &hp_state[i * INIT_SIZE_BYTE], INIT_SIZE_BLK); + } + } + else + { + oaes_key_import_data(aes_ctx, &state.hs.b[32], AES_KEY_SIZE); + for(i = 0; i < MEMORY / INIT_SIZE_BYTE; i++) + { + for(j = 0; j < INIT_SIZE_BLK; j++) + { + xor_blocks(&text[j * AES_BLOCK_SIZE], &hp_state[i * INIT_SIZE_BYTE + j * AES_BLOCK_SIZE]); + aesb_pseudo_round(&text[AES_BLOCK_SIZE * j], &text[AES_BLOCK_SIZE * j], aes_ctx->key->exp_data); + } + } + oaes_free((OAES_CTX **) &aes_ctx); + } + + /* CryptoNight Step 5: Apply Keccak to the state again, and then + * use the resulting data to select which of four finalizer + * hash functions to apply to the data (Blake, Groestl, JH, or Skein). + * Use this hash to squeeze the state array down + * to the final 256 bit hash output. + */ + + memcpy(state.init, text, INIT_SIZE_BYTE); + hash_permutation(&state.hs); + extra_hashes[state.hs.b[0] & 3](&state, 200, hash); +} + +#elif !defined NO_AES && (defined(__arm__) || defined(__aarch64__)) +void slow_hash_allocate_state(void) +{ + // Do nothing, this is just to maintain compatibility with the upgraded slow-hash.c + return; +} + +void slow_hash_free_state(void) +{ + // As above + return; +} + +#if defined(__GNUC__) +#define RDATA_ALIGN16 __attribute__ ((aligned(16))) +#define STATIC static +#define INLINE inline +#else +#define RDATA_ALIGN16 +#define STATIC static +#define INLINE +#endif + +#define U64(x) ((uint64_t *) (x)) + +STATIC INLINE void xor64(uint64_t *a, const uint64_t b) +{ + *a ^= b; +} + +#pragma pack(push, 1) +union cn_slow_hash_state +{ + union hash_state hs; + struct + { + uint8_t k[64]; + uint8_t init[INIT_SIZE_BYTE]; + }; +}; +#pragma pack(pop) + +#if defined(__aarch64__) && defined(__ARM_FEATURE_CRYPTO) + +/* ARMv8-A optimized with NEON and AES instructions. + * Copied from the x86-64 AES-NI implementation. It has much the same + * characteristics as x86-64: there's no 64x64=128 multiplier for vectors, + * and moving between vector and regular registers stalls the pipeline. + */ +#include + +#define TOTALBLOCKS (MEMORY / AES_BLOCK_SIZE) + +#define state_index(x) (((*((uint64_t *)x) >> 4) & (TOTALBLOCKS - 1)) << 4) +#define __mul() __asm__("mul %0, %1, %2\n\t" : "=r"(lo) : "r"(c[0]), "r"(b[0]) ); \ + __asm__("umulh %0, %1, %2\n\t" : "=r"(hi) : "r"(c[0]), "r"(b[0]) ); + +#define pre_aes() \ + j = state_index(a); \ + _c = vld1q_u8(&hp_state[j]); \ + _a = vld1q_u8((const uint8_t *)a); \ + +#define post_aes() \ + VARIANT2_SHUFFLE_ADD_NEON(hp_state, j); \ + vst1q_u8((uint8_t *)c, _c); \ + vst1q_u8(&hp_state[j], veorq_u8(_b, _c)); \ + VARIANT1_1(&hp_state[j]); \ + j = state_index(c); \ + p = U64(&hp_state[j]); \ + b[0] = p[0]; b[1] = p[1]; \ + VARIANT2_PORTABLE_INTEGER_MATH(b, c); \ + __mul(); \ + VARIANT2_2(); \ + VARIANT2_SHUFFLE_ADD_NEON(hp_state, j); \ + a[0] += hi; a[1] += lo; \ + p = U64(&hp_state[j]); \ + p[0] = a[0]; p[1] = a[1]; \ + a[0] ^= b[0]; a[1] ^= b[1]; \ + VARIANT1_2(p + 1); \ + _b1 = _b; \ + _b = _c; \ + + +/* Note: this was based on a standard 256bit key schedule but + * it's been shortened since Cryptonight doesn't use the full + * key schedule. Don't try to use this for vanilla AES. +*/ +static void aes_expand_key(const uint8_t *key, uint8_t *expandedKey) { +static const int rcon[] = { + 0x01,0x01,0x01,0x01, + 0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d,0x0c0f0e0d, // rotate-n-splat + 0x1b,0x1b,0x1b,0x1b }; +__asm__( +" eor v0.16b,v0.16b,v0.16b\n" +" ld1 {v3.16b},[%0],#16\n" +" ld1 {v1.4s,v2.4s},[%2],#32\n" +" ld1 {v4.16b},[%0]\n" +" mov w2,#5\n" +" st1 {v3.4s},[%1],#16\n" +"\n" +"1:\n" +" tbl v6.16b,{v4.16b},v2.16b\n" +" ext v5.16b,v0.16b,v3.16b,#12\n" +" st1 {v4.4s},[%1],#16\n" +" aese v6.16b,v0.16b\n" +" subs w2,w2,#1\n" +"\n" +" eor v3.16b,v3.16b,v5.16b\n" +" ext v5.16b,v0.16b,v5.16b,#12\n" +" eor v3.16b,v3.16b,v5.16b\n" +" ext v5.16b,v0.16b,v5.16b,#12\n" +" eor v6.16b,v6.16b,v1.16b\n" +" eor v3.16b,v3.16b,v5.16b\n" +" shl v1.16b,v1.16b,#1\n" +" eor v3.16b,v3.16b,v6.16b\n" +" st1 {v3.4s},[%1],#16\n" +" b.eq 2f\n" +"\n" +" dup v6.4s,v3.s[3] // just splat\n" +" ext v5.16b,v0.16b,v4.16b,#12\n" +" aese v6.16b,v0.16b\n" +"\n" +" eor v4.16b,v4.16b,v5.16b\n" +" ext v5.16b,v0.16b,v5.16b,#12\n" +" eor v4.16b,v4.16b,v5.16b\n" +" ext v5.16b,v0.16b,v5.16b,#12\n" +" eor v4.16b,v4.16b,v5.16b\n" +"\n" +" eor v4.16b,v4.16b,v6.16b\n" +" b 1b\n" +"\n" +"2:\n" : : "r"(key), "r"(expandedKey), "r"(rcon)); +} + +/* An ordinary AES round is a sequence of SubBytes, ShiftRows, MixColumns, AddRoundKey. There + * is also an InitialRound which consists solely of AddRoundKey. The ARM instructions slice + * this sequence differently; the aese instruction performs AddRoundKey, SubBytes, ShiftRows. + * The aesmc instruction does the MixColumns. Since the aese instruction moves the AddRoundKey + * up front, and Cryptonight's hash skips the InitialRound step, we have to kludge it here by + * feeding in a vector of zeros for our first step. Also we have to do our own Xor explicitly + * at the last step, to provide the AddRoundKey that the ARM instructions omit. + */ +STATIC INLINE void aes_pseudo_round(const uint8_t *in, uint8_t *out, const uint8_t *expandedKey, int nblocks) +{ + const uint8x16_t *k = (const uint8x16_t *)expandedKey, zero = {0}; + uint8x16_t tmp; + int i; + + for (i=0; ikey->exp_data, aes_ctx->key->exp_data_len); + for(i = 0; i < MEMORY / INIT_SIZE_BYTE; i++) + { + for(j = 0; j < INIT_SIZE_BLK; j++) + aesb_pseudo_round(&text[AES_BLOCK_SIZE * j], &text[AES_BLOCK_SIZE * j], expandedKey); + memcpy(&long_state[i * INIT_SIZE_BYTE], text, INIT_SIZE_BYTE); + } + + U64(a)[0] = U64(&state.k[0])[0] ^ U64(&state.k[32])[0]; + U64(a)[1] = U64(&state.k[0])[1] ^ U64(&state.k[32])[1]; + U64(b)[0] = U64(&state.k[16])[0] ^ U64(&state.k[48])[0]; + U64(b)[1] = U64(&state.k[16])[1] ^ U64(&state.k[48])[1]; + + VARIANT_ZLX(); + + for(i = 0; i < iterations / 2; i++) + { + #define MASK ((uint32_t)(((MEMORY / AES_BLOCK_SIZE) - 1) << 4)) + #define state_index(x) ((*(uint32_t *) x) & MASK) + + // Iteration 1 + j = state_index(a); + p = &long_state[j]; + aesb_single_round(p, p, a); + copy_block(c1, p); + + VARIANT2_PORTABLE_SHUFFLE_ADD(long_state, j); + xor_blocks(p, b); + VARIANT1_1(p); + + // Iteration 2 + j = state_index(c1); + p = &long_state[j]; + copy_block(c, p); + + VARIANT2_PORTABLE_INTEGER_MATH(c, c1); + mul(c1, c, d); + VARIANT2_2_PORTABLE(); + VARIANT2_PORTABLE_SHUFFLE_ADD(long_state, j); + sum_half_blocks(a, d); + swap_blocks(a, c); + xor_blocks(a, c); + VARIANT1_2(U64(c) + 1); + copy_block(p, c); + + if (variant >= 2) { + copy_block(b + AES_BLOCK_SIZE, b); + } + copy_block(b, c1); + } + + memcpy(text, state.init, INIT_SIZE_BYTE); + oaes_key_import_data(aes_ctx, &state.hs.b[32], AES_KEY_SIZE); + memcpy(expandedKey, aes_ctx->key->exp_data, aes_ctx->key->exp_data_len); + for(i = 0; i < MEMORY / INIT_SIZE_BYTE; i++) + { + for(j = 0; j < INIT_SIZE_BLK; j++) + { + xor_blocks(&text[j * AES_BLOCK_SIZE], &long_state[i * INIT_SIZE_BYTE + j * AES_BLOCK_SIZE]); + aesb_pseudo_round(&text[AES_BLOCK_SIZE * j], &text[AES_BLOCK_SIZE * j], expandedKey); + } + } + + oaes_free((OAES_CTX **) &aes_ctx); + memcpy(state.init, text, INIT_SIZE_BYTE); + hash_permutation(&state.hs); + extra_hashes[state.hs.b[0] & 3](&state, 200, hash); +#ifdef FORCE_USE_HEAP + free(long_state); +#endif +} +#endif /* !aarch64 || !crypto */ + +#else +// Portable implementation as a fallback + +void slow_hash_allocate_state(void) +{ + // Do nothing, this is just to maintain compatibility with the upgraded slow-hash.c + return; +} + +void slow_hash_free_state(void) +{ + // As above + return; +} + +static void (*const extra_hashes[4])(const void *, size_t, char *) = { + hash_extra_blake, hash_extra_groestl, hash_extra_jh, hash_extra_skein +}; + +//extern int aesb_single_round(const uint8_t *in, uint8_t*out, const uint8_t *expandedKey); +//extern int aesb_pseudo_round(const uint8_t *in, uint8_t *out, const uint8_t *expandedKey); + +static size_t e2i(const uint8_t* a, size_t count) { return (SWAP64LE(*((uint64_t*)a)) / AES_BLOCK_SIZE) & (count - 1); } + +static void mul(const uint8_t* a, const uint8_t* b, uint8_t* res) { + uint64_t a0, b0; + uint64_t hi, lo; + + a0 = SWAP64LE(((uint64_t*)a)[0]); + b0 = SWAP64LE(((uint64_t*)b)[0]); + lo = mul128(a0, b0, &hi); + ((uint64_t*)res)[0] = SWAP64LE(hi); + ((uint64_t*)res)[1] = SWAP64LE(lo); +} + +static void sum_half_blocks(uint8_t* a, const uint8_t* b) { + uint64_t a0, a1, b0, b1; + + a0 = SWAP64LE(((uint64_t*)a)[0]); + a1 = SWAP64LE(((uint64_t*)a)[1]); + b0 = SWAP64LE(((uint64_t*)b)[0]); + b1 = SWAP64LE(((uint64_t*)b)[1]); + a0 += b0; + a1 += b1; + ((uint64_t*)a)[0] = SWAP64LE(a0); + ((uint64_t*)a)[1] = SWAP64LE(a1); +} +#define U64(x) ((uint64_t *) (x)) + +static void copy_block(uint8_t* dst, const uint8_t* src) { + memcpy(dst, src, AES_BLOCK_SIZE); +} + +static void swap_blocks(uint8_t *a, uint8_t *b){ + uint64_t t[2]; + U64(t)[0] = U64(a)[0]; + U64(t)[1] = U64(a)[1]; + U64(a)[0] = U64(b)[0]; + U64(a)[1] = U64(b)[1]; + U64(b)[0] = U64(t)[0]; + U64(b)[1] = U64(t)[1]; +} + +static void xor_blocks(uint8_t* a, const uint8_t* b) { + size_t i; + for (i = 0; i < AES_BLOCK_SIZE; i++) { + a[i] ^= b[i]; + } +} + +static void xor64(uint8_t* left, const uint8_t* right) +{ + size_t i; + for (i = 0; i < 8; ++i) + { + left[i] ^= right[i]; + } +} + +#pragma pack(push, 1) +union cn_slow_hash_state { + union hash_state hs; + struct { + uint8_t k[64]; + uint8_t init[INIT_SIZE_BYTE]; + }; +}; +#pragma pack(pop) + +void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed) { +#ifndef FORCE_USE_HEAP + uint8_t long_state[MEMORY]; +#else + uint8_t *long_state = (uint8_t *)malloc(MEMORY); +#endif + + union cn_slow_hash_state state; + uint8_t text[INIT_SIZE_BYTE]; + uint8_t a[AES_BLOCK_SIZE]; + uint8_t b[AES_BLOCK_SIZE * 2]; + uint8_t c1[AES_BLOCK_SIZE]; + uint8_t c2[AES_BLOCK_SIZE]; + uint8_t d[AES_BLOCK_SIZE]; + size_t i, j; + uint8_t aes_key[AES_KEY_SIZE]; + oaes_ctx *aes_ctx; + + if (prehashed) { + memcpy(&state.hs, data, length); + } else { + hash_process(&state.hs, data, length); + } + memcpy(text, state.init, INIT_SIZE_BYTE); + memcpy(aes_key, state.hs.b, AES_KEY_SIZE); + aes_ctx = (oaes_ctx *) oaes_alloc(); + + VARIANT1_PORTABLE_INIT(); + VARIANT2_PORTABLE_INIT(); + + oaes_key_import_data(aes_ctx, aes_key, AES_KEY_SIZE); + for (i = 0; i < MEMORY / INIT_SIZE_BYTE; i++) { + for (j = 0; j < INIT_SIZE_BLK; j++) { + aesb_pseudo_round(&text[AES_BLOCK_SIZE * j], &text[AES_BLOCK_SIZE * j], aes_ctx->key->exp_data); + } + memcpy(&long_state[i * INIT_SIZE_BYTE], text, INIT_SIZE_BYTE); + } + + for (i = 0; i < AES_BLOCK_SIZE; i++) { + a[i] = state.k[ i] ^ state.k[AES_BLOCK_SIZE * 2 + i]; + b[i] = state.k[AES_BLOCK_SIZE + i] ^ state.k[AES_BLOCK_SIZE * 3 + i]; + } + + VARIANT_ZLX(); + for (i = 0; i < iterations / 2; i++) { + /* Dependency chain: address -> read value ------+ + * written value <-+ hard function (AES or MUL) <+ + * next address <-+ + */ + /* Iteration 1 */ + j = e2i(a, MEMORY / AES_BLOCK_SIZE) * AES_BLOCK_SIZE; + copy_block(c1, &long_state[j]); + aesb_single_round(c1, c1, a); + VARIANT2_PORTABLE_SHUFFLE_ADD(long_state, j); + copy_block(&long_state[j], c1); + xor_blocks(&long_state[j], b); + assert(j == e2i(a, MEMORY / AES_BLOCK_SIZE) * AES_BLOCK_SIZE); + VARIANT1_1(&long_state[j]); + /* Iteration 2 */ + j = e2i(c1, MEMORY / AES_BLOCK_SIZE) * AES_BLOCK_SIZE; + copy_block(c2, &long_state[j]); + VARIANT2_PORTABLE_INTEGER_MATH(c2, c1); + mul(c1, c2, d); + VARIANT2_2_PORTABLE(); + VARIANT2_PORTABLE_SHUFFLE_ADD(long_state, j); + swap_blocks(a, c1); + sum_half_blocks(c1, d); + swap_blocks(c1, c2); + xor_blocks(c1, c2); + VARIANT1_2(c2 + 8); + copy_block(&long_state[j], c2); + assert(j == e2i(a, MEMORY / AES_BLOCK_SIZE) * AES_BLOCK_SIZE); + if (variant >= 2) { + copy_block(b + AES_BLOCK_SIZE, b); + } + copy_block(b, a); + copy_block(a, c1); + } + + memcpy(text, state.init, INIT_SIZE_BYTE); + oaes_key_import_data(aes_ctx, &state.hs.b[32], AES_KEY_SIZE); + for (i = 0; i < MEMORY / INIT_SIZE_BYTE; i++) { + for (j = 0; j < INIT_SIZE_BLK; j++) { + xor_blocks(&text[j * AES_BLOCK_SIZE], &long_state[i * INIT_SIZE_BYTE + j * AES_BLOCK_SIZE]); + aesb_pseudo_round(&text[AES_BLOCK_SIZE * j], &text[AES_BLOCK_SIZE * j], aes_ctx->key->exp_data); + } + } + memcpy(state.init, text, INIT_SIZE_BYTE); + hash_permutation(&state.hs); + /*memcpy(hash, &state, 32);*/ + extra_hashes[state.hs.b[0] & 3](&state, 200, hash); + oaes_free((OAES_CTX **) &aes_ctx); + +#ifdef FORCE_USE_HEAP + free(long_state); +#endif +} + +#endif diff --git a/src/crypto/slow-hash_stdc.c b/src/crypto/slow-hash_stdc.c deleted file mode 100644 index 20ec81ee..00000000 --- a/src/crypto/slow-hash_stdc.c +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (c) 2012-2018, The CryptoNote developers, The Bytecoin developers. -// Licensed under the GNU Lesser General Public License. See LICENSE for details. - -#include -#include -#include -#include - -#include "hash.h" -#include "int-util.h" -#include "oaes/oaes_lib.h" -#ifdef __APPLE__ -#include "TargetConditionals.h" -#endif - -static void (*const extra_hashes[4])(const void *, size_t, struct cryptoHash *) = { - crypto_hash_extra_blake, crypto_hash_extra_groestl, crypto_hash_extra_jh, crypto_hash_extra_skein}; - -#define MEMORY (1 << 21) /* 2 MiB */ -#define ITER (1 << 20) -#define AES_BLOCK_SIZE 16 -#define AES_KEY_SIZE 32 /*16*/ -#define INIT_SIZE_BLK 8 -#define INIT_SIZE_BYTE (INIT_SIZE_BLK * AES_BLOCK_SIZE) - -static void uint_le_to_bytes(unsigned char *buf, size_t si, uint64_t val) { - for (size_t i = 0; i != si; ++i) { - buf[i] = (unsigned char)val; - val >>= 8; - } -} -static uint64_t uint_le_from_bytes(const unsigned char *buf, size_t si) { - uint64_t result = 0; - for (size_t i = si; i-- > 0;) - result = (result << 8) + buf[i]; - return result; -} - -static size_t e2i(const uint8_t *a, size_t count) { return (uint_le_from_bytes(a, 8) / AES_BLOCK_SIZE) & (count - 1); } - -static void mul(const uint8_t *a, const uint8_t *b, uint8_t *res) { - uint64_t a0, b0; - uint64_t hi, lo; - - a0 = uint_le_from_bytes(a, 8); - b0 = uint_le_from_bytes(b, 8); - lo = mul128(a0, b0, &hi); - uint_le_to_bytes(res, 8, hi); - uint_le_to_bytes(res + 8, 8, lo); -} - -static void sum_half_blocks(uint8_t *a, const uint8_t *b) { - uint64_t a0, a1, b0, b1; - - a0 = uint_le_from_bytes(a, 8); - a1 = uint_le_from_bytes(a + 8, 8); - b0 = uint_le_from_bytes(b, 8); - b1 = uint_le_from_bytes(b + 8, 8); - a0 += b0; - a1 += b1; - uint_le_to_bytes(a, 8, a0); - uint_le_to_bytes(a + 8, 8, a1); -} - -static void copy_block(uint8_t *dst, const uint8_t *src) { memcpy(dst, src, AES_BLOCK_SIZE); } - -static void swap_blocks(uint8_t *a, uint8_t *b) { - size_t i; - uint8_t t; - for (i = 0; i < AES_BLOCK_SIZE; i++) { - t = a[i]; - a[i] = b[i]; - b[i] = t; - } -} - -static void xor_blocks(uint8_t *a, const uint8_t *b) { - size_t i; - for (i = 0; i < AES_BLOCK_SIZE; i++) { - a[i] ^= b[i]; - } -} - -#pragma pack(push, 1) -union cn_slow_hash_state { - struct cryptoKeccakState hs; - struct { - uint8_t k[64]; - uint8_t init[INIT_SIZE_BYTE]; - }; -}; -#pragma pack(pop) - -void crypto_cn_slow_hash_platform_independent( - void *scratchpad, const void *data, size_t length, struct cryptoHash *hash) { - uint8_t *long_state = (uint8_t *)scratchpad; - union cn_slow_hash_state state; - uint8_t text[INIT_SIZE_BYTE]; - uint8_t a[AES_BLOCK_SIZE]; - uint8_t b[AES_BLOCK_SIZE]; - uint8_t c[AES_BLOCK_SIZE]; - uint8_t d[AES_BLOCK_SIZE]; - size_t i, j; - uint8_t aes_key[AES_KEY_SIZE]; - OAES_CTX *aes_ctx; - - crypto_keccak_into_state(data, length, &state.hs); - memcpy(text, state.init, INIT_SIZE_BYTE); - memcpy(aes_key, state.hs.b, AES_KEY_SIZE); - aes_ctx = oaes_alloc(); - - oaes_key_import_data(aes_ctx, aes_key, AES_KEY_SIZE); - for (i = 0; i < MEMORY / INIT_SIZE_BYTE; i++) { - for (j = 0; j < INIT_SIZE_BLK; j++) - oaes_pseudo_encrypt_ecb(aes_ctx, &text[AES_BLOCK_SIZE * j]); - - memcpy(&long_state[i * INIT_SIZE_BYTE], text, INIT_SIZE_BYTE); - } - - for (i = 0; i < 16; i++) { - a[i] = state.k[i] ^ state.k[32 + i]; - b[i] = state.k[16 + i] ^ state.k[48 + i]; - } - - for (i = 0; i < ITER / 2; i++) { - /* Dependency chain: address -> read value ------+ - * written value <-+ hard function (AES or MUL) <+ - * next address <-+ - */ - /* Iteration 1 */ - j = e2i(a, MEMORY / AES_BLOCK_SIZE); - copy_block(c, &long_state[j * AES_BLOCK_SIZE]); - oaes_encryption_round(a, c); - xor_blocks(b, c); - swap_blocks(b, c); - copy_block(&long_state[j * AES_BLOCK_SIZE], c); - assert(j == e2i(a, MEMORY / AES_BLOCK_SIZE)); - swap_blocks(a, b); - /* Iteration 2 */ - j = e2i(a, MEMORY / AES_BLOCK_SIZE); - copy_block(c, &long_state[j * AES_BLOCK_SIZE]); - mul(a, c, d); - sum_half_blocks(b, d); - swap_blocks(b, c); - xor_blocks(b, c); - copy_block(&long_state[j * AES_BLOCK_SIZE], c); - assert(j == e2i(a, MEMORY / AES_BLOCK_SIZE)); - swap_blocks(a, b); - } - - memcpy(text, state.init, INIT_SIZE_BYTE); - oaes_key_import_data(aes_ctx, &state.hs.b[32], AES_KEY_SIZE); - for (i = 0; i < MEMORY / INIT_SIZE_BYTE; i++) { - for (j = 0; j < INIT_SIZE_BLK; j++) { - xor_blocks(&text[j * AES_BLOCK_SIZE], &long_state[i * INIT_SIZE_BYTE + j * AES_BLOCK_SIZE]); - oaes_pseudo_encrypt_ecb(aes_ctx, &text[j * AES_BLOCK_SIZE]); - } - } - memcpy(state.init, text, INIT_SIZE_BYTE); - crypto_keccak_permutation(&state.hs); - extra_hashes[state.hs.b[0] & 3](&state, 200, hash); - oaes_free(&aes_ctx); -} - -// We need if !x86, but no portable way to express that -#if defined(__EMSCRIPTEN__) || defined(__PPC__) || TARGET_OS_IPHONE || defined(__ANDROID__) -void crypto_cn_slow_hash(void *scratchpad, const void *data, size_t length, struct cryptoHash *hash) { - crypto_cn_slow_hash_platform_independent(scratchpad, data, length, hash); -} - -#endif // TARGET_OS_IPHONE diff --git a/src/crypto/slow-hash_x86.c b/src/crypto/slow-hash_x86.c deleted file mode 100644 index 94263efa..00000000 --- a/src/crypto/slow-hash_x86.c +++ /dev/null @@ -1,191 +0,0 @@ -// Copyright (c) 2012-2018, The CryptoNote developers, The Bytecoin developers. -// Licensed under the GNU Lesser General Public License. See LICENSE for details. - -#include -#include -#include - -#ifdef __APPLE__ -#include "TargetConditionals.h" -#endif - -// We need if x86, but no portable way to express that -#if !defined(__EMSCRIPTEN__) && !defined(__PPC__) && !TARGET_OS_IPHONE && !defined(__ANDROID__) - -#include -#include - -#if defined(_MSC_VER) -#include -#else -#include -#endif - -#include "hash.h" -#include "initializer.h" -#include "int-util.h" -#include "oaes/aesb.h" -#include "oaes/oaes_lib.h" - -#if defined(__GNUC__) -#define likely(x) (__builtin_expect(!!(x), 1)) -#define unlikely(x) (__builtin_expect(!!(x), 0)) -#else -#define likely(x) (x) -#define unlikely(x) (x) -#define __attribute__(x) -#endif - -#if defined(_MSC_VER) -#define restrict -#endif - -#define MEMORY (1 << 21) /* 2 MiB */ -#define ITER (1 << 20) -#define AES_BLOCK_SIZE 16 -#define AES_KEY_SIZE 32 /*16*/ -#define INIT_SIZE_BLK 8 -#define INIT_SIZE_BYTE (INIT_SIZE_BLK * AES_BLOCK_SIZE) // 128 - -#pragma pack(push, 1) -union cn_slow_hash_state { - struct cryptoKeccakState hs; - struct { - uint8_t k[64]; - uint8_t init[INIT_SIZE_BYTE]; - }; -}; -#pragma pack(pop) - -#if defined(_MSC_VER) -#define ALIGNED_DATA(x) __declspec(align(x)) -#define ALIGNED_DECL(t, x) ALIGNED_DATA(x) t -#elif defined(__GNUC__) -#define ALIGNED_DATA(x) __attribute__((aligned(x))) -#define ALIGNED_DECL(t, x) t ALIGNED_DATA(x) -#endif - -struct cn_ctx { - ALIGNED_DECL(uint8_t long_state[MEMORY], 16); - ALIGNED_DECL(union cn_slow_hash_state state, 16); - ALIGNED_DECL(uint8_t text[INIT_SIZE_BYTE], 16); - ALIGNED_DECL(uint64_t a[AES_BLOCK_SIZE >> 3], 16); - ALIGNED_DECL(uint64_t b[AES_BLOCK_SIZE >> 3], 16); - ALIGNED_DECL(uint8_t c[AES_BLOCK_SIZE], 16); - oaes_ctx *aes_ctx; -}; - -static_assert(sizeof(struct cn_ctx) == SLOW_HASH_CONTEXT_SIZE, "Invalid structure size"); - -static void ExpandAESKey256_sub1(__m128i *tmp1, __m128i *tmp2) { - __m128i tmp4; - *tmp2 = _mm_shuffle_epi32(*tmp2, 0xFF); - tmp4 = _mm_slli_si128(*tmp1, 0x04); - *tmp1 = _mm_xor_si128(*tmp1, tmp4); - tmp4 = _mm_slli_si128(tmp4, 0x04); - *tmp1 = _mm_xor_si128(*tmp1, tmp4); - tmp4 = _mm_slli_si128(tmp4, 0x04); - *tmp1 = _mm_xor_si128(*tmp1, tmp4); - *tmp1 = _mm_xor_si128(*tmp1, *tmp2); -} - -static void ExpandAESKey256_sub2(__m128i *tmp1, __m128i *tmp3) { - __m128i tmp2, tmp4; - - tmp4 = _mm_aeskeygenassist_si128(*tmp1, 0x00); - tmp2 = _mm_shuffle_epi32(tmp4, 0xAA); - tmp4 = _mm_slli_si128(*tmp3, 0x04); - *tmp3 = _mm_xor_si128(*tmp3, tmp4); - tmp4 = _mm_slli_si128(tmp4, 0x04); - *tmp3 = _mm_xor_si128(*tmp3, tmp4); - tmp4 = _mm_slli_si128(tmp4, 0x04); - *tmp3 = _mm_xor_si128(*tmp3, tmp4); - *tmp3 = _mm_xor_si128(*tmp3, tmp2); -} - -// Special thanks to Intel for helping me -// with ExpandAESKey256() and its subroutines -static void ExpandAESKey256(uint8_t *keybuf) { - __m128i tmp1, tmp2, tmp3, *keys; - - keys = (__m128i *)keybuf; - - tmp1 = _mm_load_si128((__m128i *)keybuf); - tmp3 = _mm_load_si128((__m128i *)(keybuf + 0x10)); - - tmp2 = _mm_aeskeygenassist_si128(tmp3, 0x01); - ExpandAESKey256_sub1(&tmp1, &tmp2); - keys[2] = tmp1; - ExpandAESKey256_sub2(&tmp1, &tmp3); - keys[3] = tmp3; - - tmp2 = _mm_aeskeygenassist_si128(tmp3, 0x02); - ExpandAESKey256_sub1(&tmp1, &tmp2); - keys[4] = tmp1; - ExpandAESKey256_sub2(&tmp1, &tmp3); - keys[5] = tmp3; - - tmp2 = _mm_aeskeygenassist_si128(tmp3, 0x04); - ExpandAESKey256_sub1(&tmp1, &tmp2); - keys[6] = tmp1; - ExpandAESKey256_sub2(&tmp1, &tmp3); - keys[7] = tmp3; - - tmp2 = _mm_aeskeygenassist_si128(tmp3, 0x08); - ExpandAESKey256_sub1(&tmp1, &tmp2); - keys[8] = tmp1; - ExpandAESKey256_sub2(&tmp1, &tmp3); - keys[9] = tmp3; - - tmp2 = _mm_aeskeygenassist_si128(tmp3, 0x10); - ExpandAESKey256_sub1(&tmp1, &tmp2); - keys[10] = tmp1; - ExpandAESKey256_sub2(&tmp1, &tmp3); - keys[11] = tmp3; - - tmp2 = _mm_aeskeygenassist_si128(tmp3, 0x20); - ExpandAESKey256_sub1(&tmp1, &tmp2); - keys[12] = tmp1; - ExpandAESKey256_sub2(&tmp1, &tmp3); - keys[13] = tmp3; - - tmp2 = _mm_aeskeygenassist_si128(tmp3, 0x40); - ExpandAESKey256_sub1(&tmp1, &tmp2); - keys[14] = tmp1; -} - -static void (*const extra_hashes[4])(const void *, size_t, struct cryptoHash *) = { - crypto_hash_extra_blake, crypto_hash_extra_groestl, crypto_hash_extra_jh, crypto_hash_extra_skein}; - -#include "slow-hash_x86.inl" -#define AESNI -#include "slow-hash_x86.inl" - -static int cpu_has_aesni(void) { - int ecx; -#if defined(_MSC_VER) - int cpuinfo[4]; - __cpuid(cpuinfo, 1); - ecx = cpuinfo[2]; -#else - int a, b, d; - __cpuid(1, a, b, ecx, d); -#endif - return (ecx & (1 << 25)) ? 1 : 0; -} - -static void cn_slow_hash_runtime_aes_check(void *a, const void *b, size_t c, void *d) { - if (cpu_has_aesni()) - cn_slow_hash_aesni(a, b, c, d); - else - cn_slow_hash_noaesni(a, b, c, d); -} - -static void (*cn_slow_hash_fp)(void *, const void *, size_t, void *) = cn_slow_hash_runtime_aes_check; - -void crypto_cn_slow_hash(void *a, const void *b, size_t c, struct cryptoHash *d) { (*cn_slow_hash_fp)(a, b, c, d); } - -// If INITIALIZER fails to compile on your platform, just comment out INITIALIZER below -INITIALIZER(detect_aes) { cn_slow_hash_fp = cpu_has_aesni() ? &cn_slow_hash_aesni : &cn_slow_hash_noaesni; } - -#endif // !TARGET_OS_IPHONE diff --git a/src/crypto/slow-hash_x86.inl b/src/crypto/slow-hash_x86.inl deleted file mode 100644 index 1a2da5de..00000000 --- a/src/crypto/slow-hash_x86.inl +++ /dev/null @@ -1,180 +0,0 @@ -// Copyright (c) 2012-2018, The CryptoNote developers, The Bytecoin developers. -// Licensed under the GNU Lesser General Public License. See LICENSE for details. - -// No protection from double-include, this file is included twice in slow-hash_x86.c - -static void -#if defined(AESNI) -cn_slow_hash_aesni -#else -cn_slow_hash_noaesni -#endif - (void *restrict context, const void *restrict data, size_t length, void *restrict hash) { -#define ctx ((struct cn_ctx *)context) - ALIGNED_DECL(uint8_t ExpandedKey[256], 16); - size_t i; - __m128i *longoutput, *expkey, *xmminput, b_x; - ALIGNED_DECL(uint64_t a[2], 16); - crypto_keccak_into_state((const uint8_t *)data, length, &ctx->state.hs); - - memcpy(ctx->text, ctx->state.init, INIT_SIZE_BYTE); -#if defined(AESNI) - memcpy(ExpandedKey, ctx->state.hs.b, AES_KEY_SIZE); - ExpandAESKey256(ExpandedKey); -#else - ctx->aes_ctx = oaes_alloc(); - oaes_key_import_data(ctx->aes_ctx, ctx->state.hs.b, AES_KEY_SIZE); - memcpy(ExpandedKey, ctx->aes_ctx->key->exp_data, ctx->aes_ctx->key->exp_data_len); -#endif - - longoutput = (__m128i *)ctx->long_state; - expkey = (__m128i *)ExpandedKey; - xmminput = (__m128i *)ctx->text; - - // for (i = 0; likely(i < MEMORY); i += INIT_SIZE_BYTE) - // aesni_parallel_noxor(&ctx->long_state[i], ctx->text, ExpandedKey); - - for (i = 0; likely(i < MEMORY); i += INIT_SIZE_BYTE) { -#if defined(AESNI) - for (size_t j = 0; j < 10; j++) { - xmminput[0] = _mm_aesenc_si128(xmminput[0], expkey[j]); - xmminput[1] = _mm_aesenc_si128(xmminput[1], expkey[j]); - xmminput[2] = _mm_aesenc_si128(xmminput[2], expkey[j]); - xmminput[3] = _mm_aesenc_si128(xmminput[3], expkey[j]); - xmminput[4] = _mm_aesenc_si128(xmminput[4], expkey[j]); - xmminput[5] = _mm_aesenc_si128(xmminput[5], expkey[j]); - xmminput[6] = _mm_aesenc_si128(xmminput[6], expkey[j]); - xmminput[7] = _mm_aesenc_si128(xmminput[7], expkey[j]); - } -#else - aesb_pseudo_round((uint8_t *)&xmminput[0], (uint8_t *)&xmminput[0], (uint8_t *)expkey); - aesb_pseudo_round((uint8_t *)&xmminput[1], (uint8_t *)&xmminput[1], (uint8_t *)expkey); - aesb_pseudo_round((uint8_t *)&xmminput[2], (uint8_t *)&xmminput[2], (uint8_t *)expkey); - aesb_pseudo_round((uint8_t *)&xmminput[3], (uint8_t *)&xmminput[3], (uint8_t *)expkey); - aesb_pseudo_round((uint8_t *)&xmminput[4], (uint8_t *)&xmminput[4], (uint8_t *)expkey); - aesb_pseudo_round((uint8_t *)&xmminput[5], (uint8_t *)&xmminput[5], (uint8_t *)expkey); - aesb_pseudo_round((uint8_t *)&xmminput[6], (uint8_t *)&xmminput[6], (uint8_t *)expkey); - aesb_pseudo_round((uint8_t *)&xmminput[7], (uint8_t *)&xmminput[7], (uint8_t *)expkey); -#endif - _mm_store_si128(&(longoutput[(i >> 4)]), xmminput[0]); - _mm_store_si128(&(longoutput[(i >> 4) + 1]), xmminput[1]); - _mm_store_si128(&(longoutput[(i >> 4) + 2]), xmminput[2]); - _mm_store_si128(&(longoutput[(i >> 4) + 3]), xmminput[3]); - _mm_store_si128(&(longoutput[(i >> 4) + 4]), xmminput[4]); - _mm_store_si128(&(longoutput[(i >> 4) + 5]), xmminput[5]); - _mm_store_si128(&(longoutput[(i >> 4) + 6]), xmminput[6]); - _mm_store_si128(&(longoutput[(i >> 4) + 7]), xmminput[7]); - } - - for (i = 0; i < 2; i++) { - ctx->a[i] = ((uint64_t *)ctx->state.k)[i] ^ ((uint64_t *)ctx->state.k)[i + 4]; - ctx->b[i] = ((uint64_t *)ctx->state.k)[i + 2] ^ ((uint64_t *)ctx->state.k)[i + 6]; - } - - b_x = _mm_load_si128((__m128i *)ctx->b); - a[0] = ctx->a[0]; - a[1] = ctx->a[1]; - - for (i = 0; likely(i < 0x80000); i++) { - __m128i c_x = _mm_load_si128((__m128i *)&ctx->long_state[a[0] & 0x1FFFF0]); - __m128i a_x = _mm_load_si128((__m128i *)a); - ALIGNED_DECL(uint64_t c[2], 16); - ALIGNED_DECL(uint64_t b[2], 16); - uint64_t *nextblock, *dst; - -#if defined(AESNI) - c_x = _mm_aesenc_si128(c_x, a_x); -#else - aesb_single_round((uint8_t *)&c_x, (uint8_t *)&c_x, (uint8_t *)&a_x); -#endif - - _mm_store_si128((__m128i *)c, c_x); - //__builtin_prefetch(&ctx->long_state[c[0] & 0x1FFFF0], 0, 1); - - b_x = _mm_xor_si128(b_x, c_x); - _mm_store_si128((__m128i *)&ctx->long_state[a[0] & 0x1FFFF0], b_x); - - nextblock = (uint64_t *)&ctx->long_state[c[0] & 0x1FFFF0]; - b[0] = nextblock[0]; - b[1] = nextblock[1]; - - { - uint64_t hi, lo; - // hi,lo = 64bit x 64bit multiply of c[0] and b[0] - - //#if defined(__GNUC__) && defined(__x86_64__) - // __asm__("mulq %3\n\t" - // : "=d" (hi), - // "=a" (lo) - // : "%a" (c[0]), - // "rm" (b[0]) - // : "cc" ); - //#else - lo = mul128(c[0], b[0], &hi); - //#endif - a[0] += hi; - a[1] += lo; - } - dst = (uint64_t *)&ctx->long_state[c[0] & 0x1FFFF0]; - dst[0] = a[0]; - dst[1] = a[1]; - - a[0] ^= b[0]; - a[1] ^= b[1]; - b_x = c_x; - //__builtin_prefetch(&ctx->long_state[a[0] & 0x1FFFF0], 0, 3); - } - - memcpy(ctx->text, ctx->state.init, INIT_SIZE_BYTE); -#if defined(AESNI) - memcpy(ExpandedKey, &ctx->state.hs.b[32], AES_KEY_SIZE); - ExpandAESKey256(ExpandedKey); -#else - oaes_key_import_data(ctx->aes_ctx, &ctx->state.hs.b[32], AES_KEY_SIZE); - memcpy(ExpandedKey, ctx->aes_ctx->key->exp_data, ctx->aes_ctx->key->exp_data_len); -#endif - - // for (i = 0; likely(i < MEMORY); i += INIT_SIZE_BYTE) - // aesni_parallel_xor(&ctx->text, ExpandedKey, &ctx->long_state[i]); - - for (i = 0; likely(i < MEMORY); i += INIT_SIZE_BYTE) { - xmminput[0] = _mm_xor_si128(longoutput[(i >> 4)], xmminput[0]); - xmminput[1] = _mm_xor_si128(longoutput[(i >> 4) + 1], xmminput[1]); - xmminput[2] = _mm_xor_si128(longoutput[(i >> 4) + 2], xmminput[2]); - xmminput[3] = _mm_xor_si128(longoutput[(i >> 4) + 3], xmminput[3]); - xmminput[4] = _mm_xor_si128(longoutput[(i >> 4) + 4], xmminput[4]); - xmminput[5] = _mm_xor_si128(longoutput[(i >> 4) + 5], xmminput[5]); - xmminput[6] = _mm_xor_si128(longoutput[(i >> 4) + 6], xmminput[6]); - xmminput[7] = _mm_xor_si128(longoutput[(i >> 4) + 7], xmminput[7]); - -#if defined(AESNI) - for (size_t j = 0; j < 10; j++) { - xmminput[0] = _mm_aesenc_si128(xmminput[0], expkey[j]); - xmminput[1] = _mm_aesenc_si128(xmminput[1], expkey[j]); - xmminput[2] = _mm_aesenc_si128(xmminput[2], expkey[j]); - xmminput[3] = _mm_aesenc_si128(xmminput[3], expkey[j]); - xmminput[4] = _mm_aesenc_si128(xmminput[4], expkey[j]); - xmminput[5] = _mm_aesenc_si128(xmminput[5], expkey[j]); - xmminput[6] = _mm_aesenc_si128(xmminput[6], expkey[j]); - xmminput[7] = _mm_aesenc_si128(xmminput[7], expkey[j]); - } -#else - aesb_pseudo_round((uint8_t *)&xmminput[0], (uint8_t *)&xmminput[0], (uint8_t *)expkey); - aesb_pseudo_round((uint8_t *)&xmminput[1], (uint8_t *)&xmminput[1], (uint8_t *)expkey); - aesb_pseudo_round((uint8_t *)&xmminput[2], (uint8_t *)&xmminput[2], (uint8_t *)expkey); - aesb_pseudo_round((uint8_t *)&xmminput[3], (uint8_t *)&xmminput[3], (uint8_t *)expkey); - aesb_pseudo_round((uint8_t *)&xmminput[4], (uint8_t *)&xmminput[4], (uint8_t *)expkey); - aesb_pseudo_round((uint8_t *)&xmminput[5], (uint8_t *)&xmminput[5], (uint8_t *)expkey); - aesb_pseudo_round((uint8_t *)&xmminput[6], (uint8_t *)&xmminput[6], (uint8_t *)expkey); - aesb_pseudo_round((uint8_t *)&xmminput[7], (uint8_t *)&xmminput[7], (uint8_t *)expkey); -#endif - } - -#if !defined(AESNI) - oaes_free((OAES_CTX **)&ctx->aes_ctx); -#endif - - memcpy(ctx->state.init, ctx->text, INIT_SIZE_BYTE); - crypto_keccak_permutation(&ctx->state.hs); - extra_hashes[ctx->state.hs.b[0] & 3](&ctx->state, 200, hash); -} diff --git a/src/crypto/tree-hash.c b/src/crypto/tree-hash.c old mode 100644 new mode 100755 diff --git a/src/crypto/tree-hash.h b/src/crypto/tree-hash.h old mode 100644 new mode 100755 diff --git a/src/crypto/types.cpp b/src/crypto/types.cpp old mode 100644 new mode 100755 diff --git a/src/crypto/types.hpp b/src/crypto/types.hpp old mode 100644 new mode 100755 diff --git a/src/crypto/variant2_int_sqrt.h b/src/crypto/variant2_int_sqrt.h new file mode 100644 index 00000000..b405bb79 --- /dev/null +++ b/src/crypto/variant2_int_sqrt.h @@ -0,0 +1,163 @@ +#ifndef VARIANT2_INT_SQRT_H +#define VARIANT2_INT_SQRT_H + +#include +#include + +#define VARIANT2_INTEGER_MATH_SQRT_STEP_SSE2() \ + do { \ + const __m128i exp_double_bias = _mm_set_epi64x(0, 1023ULL << 52); \ + __m128d x = _mm_castsi128_pd(_mm_add_epi64(_mm_cvtsi64_si128(sqrt_input >> 12), exp_double_bias)); \ + x = _mm_sqrt_sd(_mm_setzero_pd(), x); \ + sqrt_result = (uint64_t)(_mm_cvtsi128_si64(_mm_sub_epi64(_mm_castpd_si128(x), exp_double_bias))) >> 19; \ + } while(0) + +#define VARIANT2_INTEGER_MATH_SQRT_STEP_FP64() \ + do { \ + sqrt_result = sqrt(sqrt_input + 18446744073709551616.0) * 2.0 - 8589934592.0; \ + } while(0) + +#define VARIANT2_INTEGER_MATH_SQRT_STEP_REF() \ + sqrt_result = integer_square_root_v2(sqrt_input) + +// Reference implementation of the integer square root for Cryptonight variant 2 +// Computes integer part of "sqrt(2^64 + n) * 2 - 2^33" +// +// In other words, given 64-bit unsigned integer n: +// 1) Write it as x = 1.NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN000... in binary (1 <= x < 2, all 64 bits of n are used) +// 2) Calculate sqrt(x) = 1.0RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR... (1 <= sqrt(x) < sqrt(2), so it will always start with "1.0" in binary) +// 3) Take 32 bits that come after "1.0" and return them as a 32-bit unsigned integer, discard all remaining bits +// +// Some sample inputs and outputs: +// +// Input | Output | Exact value of "sqrt(2^64 + n) * 2 - 2^33" +// -----------------|------------|------------------------------------------- +// 0 | 0 | 0 +// 2^32 | 0 | 0.99999999994179233909330885695244... +// 2^32 + 1 | 1 | 1.0000000001746229827200734316305... +// 2^50 | 262140 | 262140.00012206565608606978175873... +// 2^55 + 20963331 | 8384515 | 8384515.9999999997673963974959744... +// 2^55 + 20963332 | 8384516 | 8384516 +// 2^62 + 26599786 | 1013904242 | 1013904242.9999999999479374853545... +// 2^62 + 26599787 | 1013904243 | 1013904243.0000000001561875439364... +// 2^64 - 1 | 3558067407 | 3558067407.9041987696409179931096... + +// The reference implementation as it is now uses only unsigned int64 arithmetic, so it can't have undefined behavior +// It was tested once for all edge cases and confirmed correct +static inline uint32_t integer_square_root_v2(uint64_t n) +{ + uint64_t r = 1ULL << 63; + + for (uint64_t bit = 1ULL << 60; bit; bit >>= 2) + { + const bool b = (n < r + bit); + const uint64_t n_next = n - (r + bit); + const uint64_t r_next = r + bit * 2; + n = b ? n : n_next; + r = b ? r : r_next; + r >>= 1; + } + + return r * 2 + ((n > r) ? 1 : 0); +} + +/* +VARIANT2_INTEGER_MATH_SQRT_FIXUP checks that "r" is an integer part of "sqrt(2^64 + sqrt_input) * 2 - 2^33" and adds or subtracts 1 if needed +It's hard to understand how it works, so here is a full calculation of formulas used in VARIANT2_INTEGER_MATH_SQRT_FIXUP + +The following inequalities must hold for r if it's an integer part of "sqrt(2^64 + sqrt_input) * 2 - 2^33": +1) r <= sqrt(2^64 + sqrt_input) * 2 - 2^33 +2) r + 1 > sqrt(2^64 + sqrt_input) * 2 - 2^33 + +We need to check them using only unsigned integer arithmetic to avoid rounding errors and undefined behavior + +First inequality: r <= sqrt(2^64 + sqrt_input) * 2 - 2^33 +----------------------------------------------------------------------------------- +r <= sqrt(2^64 + sqrt_input) * 2 - 2^33 +r + 2^33 <= sqrt(2^64 + sqrt_input) * 2 +r/2 + 2^32 <= sqrt(2^64 + sqrt_input) +(r/2 + 2^32)^2 <= 2^64 + sqrt_input + +Rewrite r as r = s * 2 + b (s = trunc(r/2), b is 0 or 1) + +((s*2+b)/2 + 2^32)^2 <= 2^64 + sqrt_input +(s*2+b)^2/4 + 2*2^32*(s*2+b)/2 + 2^64 <= 2^64 + sqrt_input +(s*2+b)^2/4 + 2*2^32*(s*2+b)/2 <= sqrt_input +(s*2+b)^2/4 + 2^32*r <= sqrt_input +(s^2*4+2*s*2*b+b^2)/4 + 2^32*r <= sqrt_input +s^2+s*b+b^2/4 + 2^32*r <= sqrt_input +s*(s+b) + b^2/4 + 2^32*r <= sqrt_input + +Let r2 = s*(s+b) + r*2^32 +r2 + b^2/4 <= sqrt_input + +If this inequality doesn't hold, then we must decrement r: IF "r2 + b^2/4 > sqrt_input" THEN r = r - 1 + +b can be 0 or 1 +If b is 0 then we need to compare "r2 > sqrt_input" +If b is 1 then b^2/4 = 0.25, so we need to compare "r2 + 0.25 > sqrt_input" +Since both r2 and sqrt_input are integers, we can safely replace it with "r2 + 1 > sqrt_input" +----------------------------------------------------------------------------------- +Both cases can be merged to a single expression "r2 + b > sqrt_input" +----------------------------------------------------------------------------------- +There will be no overflow when calculating "r2 + b", so it's safe to compare with sqrt_input: +r2 + b = s*(s+b) + r*2^32 + b +The largest value s, b and r can have is s = 1779033703, b = 1, r = 3558067407 when sqrt_input = 2^64 - 1 +r2 + b <= 1779033703*1779033704 + 3558067407*2^32 + 1 = 18446744068217447385 < 2^64 + +Second inequality: r + 1 > sqrt(2^64 + sqrt_input) * 2 - 2^33 +----------------------------------------------------------------------------------- +r + 1 > sqrt(2^64 + sqrt_input) * 2 - 2^33 +r + 1 + 2^33 > sqrt(2^64 + sqrt_input) * 2 +((r+1)/2 + 2^32)^2 > 2^64 + sqrt_input + +Rewrite r as r = s * 2 + b (s = trunc(r/2), b is 0 or 1) + +((s*2+b+1)/2 + 2^32)^2 > 2^64 + sqrt_input +(s*2+b+1)^2/4 + 2*(s*2+b+1)/2*2^32 + 2^64 > 2^64 + sqrt_input +(s*2+b+1)^2/4 + (s*2+b+1)*2^32 > sqrt_input +(s*2+b+1)^2/4 + (r+1)*2^32 > sqrt_input +(s*2+(b+1))^2/4 + r*2^32 + 2^32 > sqrt_input +(s^2*4+2*s*2*(b+1)+(b+1)^2)/4 + r*2^32 + 2^32 > sqrt_input +s^2+s*(b+1)+(b+1)^2/4 + r*2^32 + 2^32 > sqrt_input +s*(s+b) + s + (b+1)^2/4 + r*2^32 + 2^32 > sqrt_input + +Let r2 = s*(s+b) + r*2^32 + +r2 + s + (b+1)^2/4 + 2^32 > sqrt_input +r2 + 2^32 + (b+1)^2/4 > sqrt_input - s + +If this inequality doesn't hold, then we must decrement r: IF "r2 + 2^32 + (b+1)^2/4 <= sqrt_input - s" THEN r = r - 1 +b can be 0 or 1 +If b is 0 then we need to compare "r2 + 2^32 + 1/4 <= sqrt_input - s" which is equal to "r2 + 2^32 < sqrt_input - s" because all numbers here are integers +If b is 1 then (b+1)^2/4 = 1, so we need to compare "r2 + 2^32 + 1 <= sqrt_input - s" which is also equal to "r2 + 2^32 < sqrt_input - s" +----------------------------------------------------------------------------------- +Both cases can be merged to a single expression "r2 + 2^32 < sqrt_input - s" +----------------------------------------------------------------------------------- +There will be no overflow when calculating "r2 + 2^32": +r2 + 2^32 = s*(s+b) + r*2^32 + 2^32 = s*(s+b) + (r+1)*2^32 +The largest value s, b and r can have is s = 1779033703, b = 1, r = 3558067407 when sqrt_input = 2^64 - 1 +r2 + b <= 1779033703*1779033704 + 3558067408*2^32 = 18446744072512414680 < 2^64 + +There will be no integer overflow when calculating "sqrt_input - s", i.e. "sqrt_input >= s" at all times: +s = trunc(r/2) = trunc(sqrt(2^64 + sqrt_input) - 2^32) < sqrt(2^64 + sqrt_input) - 2^32 + 1 +sqrt_input > sqrt(2^64 + sqrt_input) - 2^32 + 1 +sqrt_input + 2^32 - 1 > sqrt(2^64 + sqrt_input) +(sqrt_input + 2^32 - 1)^2 > sqrt_input + 2^64 +sqrt_input^2 + 2*sqrt_input*(2^32 - 1) + (2^32-1)^2 > sqrt_input + 2^64 +sqrt_input^2 + sqrt_input*(2^33 - 2) + (2^32-1)^2 > sqrt_input + 2^64 +sqrt_input^2 + sqrt_input*(2^33 - 3) + (2^32-1)^2 > 2^64 +sqrt_input^2 + sqrt_input*(2^33 - 3) + 2^64-2^33+1 > 2^64 +sqrt_input^2 + sqrt_input*(2^33 - 3) - 2^33 + 1 > 0 +This inequality is true if sqrt_input > 1 and it's easy to check that s = 0 if sqrt_input is 0 or 1, so there will be no integer overflow +*/ + +#define VARIANT2_INTEGER_MATH_SQRT_FIXUP(r) \ + do { \ + const uint64_t s = r >> 1; \ + const uint64_t b = r & 1; \ + const uint64_t r2 = (uint64_t)(s) * (s + b) + (r << 32); \ + r += ((r2 + b > sqrt_input) ? -1 : 0) + ((r2 + (1ULL << 32) < sqrt_input - s) ? 1 : 0); \ + } while(0) + +#endif diff --git a/src/http/Agent.cpp b/src/http/Agent.cpp old mode 100644 new mode 100755 diff --git a/src/http/Agent.hpp b/src/http/Agent.hpp old mode 100644 new mode 100755 diff --git a/src/http/BinaryRpc.hpp b/src/http/BinaryRpc.hpp old mode 100644 new mode 100755 diff --git a/src/http/Client.cpp b/src/http/Client.cpp old mode 100644 new mode 100755 diff --git a/src/http/Client.hpp b/src/http/Client.hpp old mode 100644 new mode 100755 diff --git a/src/http/JsonRpc.cpp b/src/http/JsonRpc.cpp old mode 100644 new mode 100755 index be2f50c8..92635d1a --- a/src/http/JsonRpc.cpp +++ b/src/http/JsonRpc.cpp @@ -77,7 +77,7 @@ void Request::parse(const std::string &request_body, bool allow_empty_id) { throw Error(INVALID_REQUEST, "id value must be number, string or null"); jid = std::move(p); stripped_req.erase("id"); - } else { + } else { if (!allow_empty_id) throw Error(INVALID_REQUEST, "id value is REQUIRED"); } diff --git a/src/http/JsonRpc.hpp b/src/http/JsonRpc.hpp old mode 100644 new mode 100755 index 87541f8f..fa67d319 --- a/src/http/JsonRpc.hpp +++ b/src/http/JsonRpc.hpp @@ -41,7 +41,7 @@ typedef boost::optional OptionalJsonValue; class Request { public: Request() = default; - explicit Request(const std::string &request_body, bool allow_empty_id = false) { + explicit Request(const std::string &request_body, bool allow_empty_id = false) { parse(request_body, allow_empty_id); } template diff --git a/src/http/RequestParser.cpp b/src/http/RequestParser.cpp old mode 100644 new mode 100755 diff --git a/src/http/RequestParser.hpp b/src/http/RequestParser.hpp old mode 100644 new mode 100755 diff --git a/src/http/ResponseParser.cpp b/src/http/ResponseParser.cpp old mode 100644 new mode 100755 diff --git a/src/http/ResponseParser.hpp b/src/http/ResponseParser.hpp old mode 100644 new mode 100755 diff --git a/src/http/Server.cpp b/src/http/Server.cpp old mode 100644 new mode 100755 diff --git a/src/http/Server.hpp b/src/http/Server.hpp old mode 100644 new mode 100755 diff --git a/src/http/types.cpp b/src/http/types.cpp old mode 100644 new mode 100755 diff --git a/src/http/types.hpp b/src/http/types.hpp old mode 100644 new mode 100755 diff --git a/src/logging/CommonLogger.cpp b/src/logging/CommonLogger.cpp old mode 100644 new mode 100755 diff --git a/src/logging/CommonLogger.hpp b/src/logging/CommonLogger.hpp old mode 100644 new mode 100755 diff --git a/src/logging/ConsoleLogger.cpp b/src/logging/ConsoleLogger.cpp old mode 100644 new mode 100755 diff --git a/src/logging/ConsoleLogger.hpp b/src/logging/ConsoleLogger.hpp old mode 100644 new mode 100755 diff --git a/src/logging/FileLogger.cpp b/src/logging/FileLogger.cpp old mode 100644 new mode 100755 diff --git a/src/logging/FileLogger.hpp b/src/logging/FileLogger.hpp old mode 100644 new mode 100755 diff --git a/src/logging/ILogger.cpp b/src/logging/ILogger.cpp old mode 100644 new mode 100755 diff --git a/src/logging/ILogger.hpp b/src/logging/ILogger.hpp old mode 100644 new mode 100755 diff --git a/src/logging/LoggerGroup.cpp b/src/logging/LoggerGroup.cpp old mode 100644 new mode 100755 diff --git a/src/logging/LoggerGroup.hpp b/src/logging/LoggerGroup.hpp old mode 100644 new mode 100755 diff --git a/src/logging/LoggerManager.cpp b/src/logging/LoggerManager.cpp old mode 100644 new mode 100755 diff --git a/src/logging/LoggerManager.hpp b/src/logging/LoggerManager.hpp old mode 100644 new mode 100755 diff --git a/src/logging/LoggerMessage.cpp b/src/logging/LoggerMessage.cpp old mode 100644 new mode 100755 diff --git a/src/logging/LoggerMessage.hpp b/src/logging/LoggerMessage.hpp old mode 100644 new mode 100755 diff --git a/src/main_bytecoind.cpp b/src/main_bytecoind.cpp old mode 100644 new mode 100755 diff --git a/src/main_fuzzer.cpp b/src/main_fuzzer.cpp old mode 100644 new mode 100755 diff --git a/src/main_miner.cpp b/src/main_miner.cpp old mode 100644 new mode 100755 diff --git a/src/main_tests.cpp b/src/main_tests.cpp old mode 100644 new mode 100755 diff --git a/src/main_walletd.cpp b/src/main_walletd.cpp old mode 100644 new mode 100755 diff --git a/src/p2p/LevinProtocol.cpp b/src/p2p/LevinProtocol.cpp old mode 100644 new mode 100755 diff --git a/src/p2p/LevinProtocol.hpp b/src/p2p/LevinProtocol.hpp old mode 100644 new mode 100755 diff --git a/src/p2p/P2P.cpp b/src/p2p/P2P.cpp old mode 100644 new mode 100755 diff --git a/src/p2p/P2P.hpp b/src/p2p/P2P.hpp old mode 100644 new mode 100755 diff --git a/src/p2p/P2PProtocolBasic.cpp b/src/p2p/P2PProtocolBasic.cpp old mode 100644 new mode 100755 diff --git a/src/p2p/P2PProtocolBasic.hpp b/src/p2p/P2PProtocolBasic.hpp old mode 100644 new mode 100755 diff --git a/src/p2p/P2pProtocolDefinitions.hpp b/src/p2p/P2pProtocolDefinitions.hpp old mode 100644 new mode 100755 diff --git a/src/p2p/P2pProtocolTypes.hpp b/src/p2p/P2pProtocolTypes.hpp old mode 100644 new mode 100755 diff --git a/src/p2p/P2pSeria.cpp b/src/p2p/P2pSeria.cpp old mode 100644 new mode 100755 diff --git a/src/p2p/PeerDB.cpp b/src/p2p/PeerDB.cpp old mode 100644 new mode 100755 diff --git a/src/p2p/PeerDB.hpp b/src/p2p/PeerDB.hpp old mode 100644 new mode 100755 diff --git a/src/platform/DB.hpp b/src/platform/DB.hpp old mode 100644 new mode 100755 diff --git a/src/platform/DBlmdb.cpp b/src/platform/DBlmdb.cpp old mode 100644 new mode 100755 diff --git a/src/platform/DBlmdb.hpp b/src/platform/DBlmdb.hpp old mode 100644 new mode 100755 diff --git a/src/platform/DBmemory.cpp b/src/platform/DBmemory.cpp old mode 100644 new mode 100755 diff --git a/src/platform/DBmemory.hpp b/src/platform/DBmemory.hpp old mode 100644 new mode 100755 diff --git a/src/platform/DBsqlite3.cpp b/src/platform/DBsqlite3.cpp old mode 100644 new mode 100755 diff --git a/src/platform/DBsqlite3.hpp b/src/platform/DBsqlite3.hpp old mode 100644 new mode 100755 diff --git a/src/platform/ExclusiveLock.cpp b/src/platform/ExclusiveLock.cpp old mode 100644 new mode 100755 diff --git a/src/platform/ExclusiveLock.hpp b/src/platform/ExclusiveLock.hpp old mode 100644 new mode 100755 diff --git a/src/platform/Files.cpp b/src/platform/Files.cpp old mode 100644 new mode 100755 diff --git a/src/platform/Files.hpp b/src/platform/Files.hpp old mode 100644 new mode 100755 diff --git a/src/platform/IndexDB.cpp b/src/platform/IndexDB.cpp old mode 100644 new mode 100755 diff --git a/src/platform/IndexDB.hpp b/src/platform/IndexDB.hpp old mode 100644 new mode 100755 diff --git a/src/platform/Network.cpp b/src/platform/Network.cpp old mode 100644 new mode 100755 diff --git a/src/platform/Network.hpp b/src/platform/Network.hpp old mode 100644 new mode 100755 diff --git a/src/platform/PathTools.cpp b/src/platform/PathTools.cpp old mode 100644 new mode 100755 diff --git a/src/platform/PathTools.hpp b/src/platform/PathTools.hpp old mode 100644 new mode 100755 diff --git a/src/platform/PathTools.mm b/src/platform/PathTools.mm old mode 100644 new mode 100755 diff --git a/src/platform/PreventSleep.cpp b/src/platform/PreventSleep.cpp old mode 100644 new mode 100755 diff --git a/src/platform/PreventSleep.hpp b/src/platform/PreventSleep.hpp old mode 100644 new mode 100755 diff --git a/src/platform/Time.cpp b/src/platform/Time.cpp old mode 100644 new mode 100755 diff --git a/src/platform/Time.hpp b/src/platform/Time.hpp old mode 100644 new mode 100755 diff --git a/src/platform/Windows.hpp b/src/platform/Windows.hpp old mode 100644 new mode 100755 diff --git a/src/rpc_api.cpp b/src/rpc_api.cpp old mode 100644 new mode 100755 index 4b92e1df..37655b68 --- a/src/rpc_api.cpp +++ b/src/rpc_api.cpp @@ -422,6 +422,7 @@ void ser_members(api::cnd::GetStatus::Response &v, ISeria &s) { seria_kv("next_block_effective_median_size", v.recommended_max_transaction_size, s); seria_kv("recommended_max_transaction_size", v.recommended_max_transaction_size, s); seria_kv("top_known_block_height", v.top_known_block_height, s); + seria_kv("already_generated_coins", v.already_generated_coins, s); } void ser_members(api::cnd::GetBlockHeader::Request &v, ISeria &s) { diff --git a/src/rpc_api.hpp b/src/rpc_api.hpp old mode 100644 new mode 100755 index 29cf30cb..1ac5a3e8 --- a/src/rpc_api.hpp +++ b/src/rpc_api.hpp @@ -258,6 +258,7 @@ struct GetStatus { // effective median size concept, but if your tx size is larger, chance it will not be included in block for // a long time (or never). bool ready_for_longpoll(const Request &other) const; + Amount already_generated_coins = 0; }; }; diff --git a/src/seria/BinaryInputStream.cpp b/src/seria/BinaryInputStream.cpp old mode 100644 new mode 100755 diff --git a/src/seria/BinaryInputStream.hpp b/src/seria/BinaryInputStream.hpp old mode 100644 new mode 100755 diff --git a/src/seria/BinaryOutputStream.cpp b/src/seria/BinaryOutputStream.cpp old mode 100644 new mode 100755 diff --git a/src/seria/BinaryOutputStream.hpp b/src/seria/BinaryOutputStream.hpp old mode 100644 new mode 100755 diff --git a/src/seria/ISeria.hpp b/src/seria/ISeria.hpp old mode 100644 new mode 100755 diff --git a/src/seria/JsonInputStream.cpp b/src/seria/JsonInputStream.cpp old mode 100644 new mode 100755 diff --git a/src/seria/JsonInputStream.hpp b/src/seria/JsonInputStream.hpp old mode 100644 new mode 100755 diff --git a/src/seria/JsonOutputStream.cpp b/src/seria/JsonOutputStream.cpp old mode 100644 new mode 100755 diff --git a/src/seria/JsonOutputStream.hpp b/src/seria/JsonOutputStream.hpp old mode 100644 new mode 100755 diff --git a/src/seria/KVBinaryCommon.hpp b/src/seria/KVBinaryCommon.hpp old mode 100644 new mode 100755 diff --git a/src/seria/KVBinaryInputStream.cpp b/src/seria/KVBinaryInputStream.cpp old mode 100644 new mode 100755 diff --git a/src/seria/KVBinaryInputStream.hpp b/src/seria/KVBinaryInputStream.hpp old mode 100644 new mode 100755 diff --git a/src/seria/KVBinaryOutputStream.cpp b/src/seria/KVBinaryOutputStream.cpp old mode 100644 new mode 100755 diff --git a/src/seria/KVBinaryOutputStream.hpp b/src/seria/KVBinaryOutputStream.hpp old mode 100644 new mode 100755 diff --git a/src/version.hpp b/src/version.hpp old mode 100644 new mode 100755 index 8bb3b66a..743a241d --- a/src/version.hpp +++ b/src/version.hpp @@ -4,8 +4,8 @@ #pragma once // defines are for Windows resource compiler -#define bytecoin_VERSION_WINDOWS_COMMA 3, 19, 7, 18 -#define bytecoin_VERSION_STRING "v3.5.1" +#define bytecoin_VERSION_WINDOWS_COMMA 0, 0, 3, 0 +#define bytecoin_VERSION_STRING "v0.0.3" #ifndef RC_INVOKED // Windows resource compiler diff --git a/tests/Random.hpp b/tests/Random.hpp old mode 100644 new mode 100755 diff --git a/tests/blockchain/test_blockchain.cpp b/tests/blockchain/test_blockchain.cpp old mode 100644 new mode 100755 diff --git a/tests/blockchain/test_blockchain.hpp b/tests/blockchain/test_blockchain.hpp old mode 100644 new mode 100755 diff --git a/tests/crypto/benchmarks.cpp b/tests/crypto/benchmarks.cpp old mode 100644 new mode 100755 diff --git a/tests/crypto/benchmarks.hpp b/tests/crypto/benchmarks.hpp old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_ge_add.txt b/tests/crypto/bernstein/test_ge_add.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_ge_check_subgroup_precomp_vartime.txt b/tests/crypto/bernstein/test_ge_check_subgroup_precomp_vartime.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_ge_double_scalarmult_base_vartime.txt b/tests/crypto/bernstein/test_ge_double_scalarmult_base_vartime.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_ge_double_scalarmult_precomp_vartime.txt b/tests/crypto/bernstein/test_ge_double_scalarmult_precomp_vartime.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_ge_dsm_precomp.txt b/tests/crypto/bernstein/test_ge_dsm_precomp.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_ge_frombytes_vartime.txt b/tests/crypto/bernstein/test_ge_frombytes_vartime.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_ge_fromfe_frombytes_vartime.txt b/tests/crypto/bernstein/test_ge_fromfe_frombytes_vartime.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_ge_mul8.txt b/tests/crypto/bernstein/test_ge_mul8.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_ge_p1p1_to_p2.txt b/tests/crypto/bernstein/test_ge_p1p1_to_p2.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_ge_p1p1_to_p3.txt b/tests/crypto/bernstein/test_ge_p1p1_to_p3.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_ge_p2_dbl.txt b/tests/crypto/bernstein/test_ge_p2_dbl.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_ge_p3_to_cached.txt b/tests/crypto/bernstein/test_ge_p3_to_cached.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_ge_p3_to_p2.txt b/tests/crypto/bernstein/test_ge_p3_to_p2.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_ge_p3_tobytes.txt b/tests/crypto/bernstein/test_ge_p3_tobytes.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_ge_scalarmult.txt b/tests/crypto/bernstein/test_ge_scalarmult.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_ge_scalarmult_base.txt b/tests/crypto/bernstein/test_ge_scalarmult_base.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_ge_sub.txt b/tests/crypto/bernstein/test_ge_sub.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_ge_tobytes.txt b/tests/crypto/bernstein/test_ge_tobytes.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_sc_add.txt b/tests/crypto/bernstein/test_sc_add.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_sc_invert.txt b/tests/crypto/bernstein/test_sc_invert.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_sc_isvalid_vartime.txt b/tests/crypto/bernstein/test_sc_isvalid_vartime.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_sc_iszero.txt b/tests/crypto/bernstein/test_sc_iszero.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_sc_mul.txt b/tests/crypto/bernstein/test_sc_mul.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_sc_mulsub.txt b/tests/crypto/bernstein/test_sc_mulsub.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_sc_reduce.txt b/tests/crypto/bernstein/test_sc_reduce.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_sc_reduce32.txt b/tests/crypto/bernstein/test_sc_reduce32.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/bernstein/test_sc_sub.txt b/tests/crypto/bernstein/test_sc_sub.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_check_key.txt b/tests/crypto/test_check_key.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_check_ring_signature.txt b/tests/crypto/test_check_ring_signature.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_check_ring_signature_amethyst.txt b/tests/crypto/test_check_ring_signature_amethyst.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_check_ring_signature_amethyst_big.txt b/tests/crypto/test_check_ring_signature_amethyst_big.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_check_scalar.txt b/tests/crypto/test_check_scalar.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_check_signature.txt b/tests/crypto/test_check_signature.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_claim_outputs_am_linkable.txt b/tests/crypto/test_claim_outputs_am_linkable.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_claim_outputs_am_unlinkable.txt b/tests/crypto/test_claim_outputs_am_unlinkable.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_claim_outputs_cryptonote.txt b/tests/crypto/test_claim_outputs_cryptonote.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_crypto.cpp b/tests/crypto/test_crypto.cpp old mode 100644 new mode 100755 diff --git a/tests/crypto/test_crypto.hpp b/tests/crypto/test_crypto.hpp old mode 100644 new mode 100755 diff --git a/tests/crypto/test_derive_output_address_am_linkable.txt b/tests/crypto/test_derive_output_address_am_linkable.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_derive_output_address_am_unlinkable.txt b/tests/crypto/test_derive_output_address_am_unlinkable.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_derive_public_key.txt b/tests/crypto/test_derive_public_key.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_derive_secret_key.txt b/tests/crypto/test_derive_secret_key.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_elligator.txt b/tests/crypto/test_elligator.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_generate_key_derivation.txt b/tests/crypto/test_generate_key_derivation.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_generate_key_image.txt b/tests/crypto/test_generate_key_image.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_generate_outputs_am_linkable.txt b/tests/crypto/test_generate_outputs_am_linkable.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_generate_outputs_am_unlinkable.txt b/tests/crypto/test_generate_outputs_am_unlinkable.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_generate_outputs_cryptonote.txt b/tests/crypto/test_generate_outputs_cryptonote.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_generate_ring_signature.txt b/tests/crypto/test_generate_ring_signature.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_generate_ring_signature_amethyst.txt b/tests/crypto/test_generate_ring_signature_amethyst.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_generate_ring_signature_amethyst_big.txt b/tests/crypto/test_generate_ring_signature_amethyst_big.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_generate_ring_signature_big.txt b/tests/crypto/test_generate_ring_signature_big.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_generate_signature.txt b/tests/crypto/test_generate_signature.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_hash_to_scalar.txt b/tests/crypto/test_hash_to_scalar.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_hash_to_subgroup.txt b/tests/crypto/test_hash_to_subgroup.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_random_keypair.txt b/tests/crypto/test_random_keypair.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_random_scalar.txt b/tests/crypto/test_random_scalar.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_secret_key_to_public_key.txt b/tests/crypto/test_secret_key_to_public_key.txt old mode 100644 new mode 100755 diff --git a/tests/crypto/test_underive_public_key.txt b/tests/crypto/test_underive_public_key.txt old mode 100644 new mode 100755 diff --git a/tests/hash/test_hash.cpp b/tests/hash/test_hash.cpp old mode 100644 new mode 100755 index 916e6af3..0a67aaf8 --- a/tests/hash/test_hash.cpp +++ b/tests/hash/test_hash.cpp @@ -35,7 +35,7 @@ static void hash_tree(const void *vdata, size_t vlength, cryptoHash *hash) { static void slow_hash(const void *data, size_t length, cryptoHash *hash) { context.cn_slow_hash(data, length, hash); crypto::Hash hash2; - crypto_cn_slow_hash_platform_independent(context.get_data(), data, length, &hash2); + //crypto_cn_slow_hash_platform_independent(context.get_data(), data, length, &hash2); crypto::Hash chash; static_cast(chash) = *hash; invariant(chash == hash2, ""); diff --git a/tests/hash/test_hash.hpp b/tests/hash/test_hash.hpp old mode 100644 new mode 100755 diff --git a/tests/hash/tests-extra-blake.txt b/tests/hash/tests-extra-blake.txt old mode 100644 new mode 100755 diff --git a/tests/hash/tests-extra-groestl.txt b/tests/hash/tests-extra-groestl.txt old mode 100644 new mode 100755 diff --git a/tests/hash/tests-extra-jh.txt b/tests/hash/tests-extra-jh.txt old mode 100644 new mode 100755 diff --git a/tests/hash/tests-extra-skein.txt b/tests/hash/tests-extra-skein.txt old mode 100644 new mode 100755 diff --git a/tests/hash/tests-fast.txt b/tests/hash/tests-fast.txt old mode 100644 new mode 100755 diff --git a/tests/hash/tests-slow.txt b/tests/hash/tests-slow.txt old mode 100644 new mode 100755 diff --git a/tests/hash/tests-tree.txt b/tests/hash/tests-tree.txt old mode 100644 new mode 100755 diff --git a/tests/io.hpp b/tests/io.hpp old mode 100644 new mode 100755 diff --git a/tests/json/fail1.json b/tests/json/fail1.json old mode 100644 new mode 100755 diff --git a/tests/json/fail10.json b/tests/json/fail10.json old mode 100644 new mode 100755 diff --git a/tests/json/fail11.json b/tests/json/fail11.json old mode 100644 new mode 100755 diff --git a/tests/json/fail12.json b/tests/json/fail12.json old mode 100644 new mode 100755 diff --git a/tests/json/fail13.json b/tests/json/fail13.json old mode 100644 new mode 100755 diff --git a/tests/json/fail14.json b/tests/json/fail14.json old mode 100644 new mode 100755 diff --git a/tests/json/fail15.json b/tests/json/fail15.json old mode 100644 new mode 100755 diff --git a/tests/json/fail16.json b/tests/json/fail16.json old mode 100644 new mode 100755 diff --git a/tests/json/fail17.json b/tests/json/fail17.json old mode 100644 new mode 100755 diff --git a/tests/json/fail18.json b/tests/json/fail18.json old mode 100644 new mode 100755 diff --git a/tests/json/fail19.json b/tests/json/fail19.json old mode 100644 new mode 100755 diff --git a/tests/json/fail2.json b/tests/json/fail2.json old mode 100644 new mode 100755 diff --git a/tests/json/fail20.json b/tests/json/fail20.json old mode 100644 new mode 100755 diff --git a/tests/json/fail21.json b/tests/json/fail21.json old mode 100644 new mode 100755 diff --git a/tests/json/fail22.json b/tests/json/fail22.json old mode 100644 new mode 100755 diff --git a/tests/json/fail23.json b/tests/json/fail23.json old mode 100644 new mode 100755 diff --git a/tests/json/fail24.json b/tests/json/fail24.json old mode 100644 new mode 100755 diff --git a/tests/json/fail25.json b/tests/json/fail25.json old mode 100644 new mode 100755 diff --git a/tests/json/fail26.json b/tests/json/fail26.json old mode 100644 new mode 100755 diff --git a/tests/json/fail27.json b/tests/json/fail27.json old mode 100644 new mode 100755 diff --git a/tests/json/fail28.json b/tests/json/fail28.json old mode 100644 new mode 100755 diff --git a/tests/json/fail29.json b/tests/json/fail29.json old mode 100644 new mode 100755 diff --git a/tests/json/fail3.json b/tests/json/fail3.json old mode 100644 new mode 100755 diff --git a/tests/json/fail30.json b/tests/json/fail30.json old mode 100644 new mode 100755 diff --git a/tests/json/fail31.json b/tests/json/fail31.json old mode 100644 new mode 100755 diff --git a/tests/json/fail32.json b/tests/json/fail32.json old mode 100644 new mode 100755 diff --git a/tests/json/fail33.json b/tests/json/fail33.json old mode 100644 new mode 100755 diff --git a/tests/json/fail34.json b/tests/json/fail34.json old mode 100644 new mode 100755 diff --git a/tests/json/fail4.json b/tests/json/fail4.json old mode 100644 new mode 100755 diff --git a/tests/json/fail5.json b/tests/json/fail5.json old mode 100644 new mode 100755 diff --git a/tests/json/fail6.json b/tests/json/fail6.json old mode 100644 new mode 100755 diff --git a/tests/json/fail7.json b/tests/json/fail7.json old mode 100644 new mode 100755 diff --git a/tests/json/fail8.json b/tests/json/fail8.json old mode 100644 new mode 100755 diff --git a/tests/json/fail9.json b/tests/json/fail9.json old mode 100644 new mode 100755 diff --git a/tests/json/pass1.json b/tests/json/pass1.json old mode 100644 new mode 100755 diff --git a/tests/json/pass2.json b/tests/json/pass2.json old mode 100644 new mode 100755 diff --git a/tests/json/pass3.json b/tests/json/pass3.json old mode 100644 new mode 100755 diff --git a/tests/json/readme.txt b/tests/json/readme.txt old mode 100644 new mode 100755 diff --git a/tests/json/test_json.cpp b/tests/json/test_json.cpp old mode 100644 new mode 100755 diff --git a/tests/json/test_json.hpp b/tests/json/test_json.hpp old mode 100644 new mode 100755 diff --git a/tests/scratchpad/readme.txt b/tests/scratchpad/readme.txt old mode 100644 new mode 100755 diff --git a/tests/wallet_file/test01.simplewallet.wallet b/tests/wallet_file/test01.simplewallet.wallet old mode 100644 new mode 100755 diff --git a/tests/wallet_file/test02.wallet b/tests/wallet_file/test02.wallet old mode 100644 new mode 100755 diff --git a/tests/wallet_file/test03.wallet b/tests/wallet_file/test03.wallet old mode 100644 new mode 100755 diff --git a/tests/wallet_file/test04.wallet b/tests/wallet_file/test04.wallet old mode 100644 new mode 100755 diff --git a/tests/wallet_file/test05.wallet b/tests/wallet_file/test05.wallet old mode 100644 new mode 100755 diff --git a/tests/wallet_file/test05v.wallet b/tests/wallet_file/test05v.wallet old mode 100644 new mode 100755 diff --git a/tests/wallet_file/test06.wallet b/tests/wallet_file/test06.wallet old mode 100644 new mode 100755 diff --git a/tests/wallet_file/test06v.wallet b/tests/wallet_file/test06v.wallet old mode 100644 new mode 100755 diff --git a/tests/wallet_file/test_wallet_file.cpp b/tests/wallet_file/test_wallet_file.cpp old mode 100644 new mode 100755 diff --git a/tests/wallet_file/test_wallet_file.hpp b/tests/wallet_file/test_wallet_file.hpp old mode 100644 new mode 100755 diff --git a/tests/wallet_state/test_wallet_state.cpp b/tests/wallet_state/test_wallet_state.cpp old mode 100644 new mode 100755 diff --git a/tests/wallet_state/test_wallet_state.hpp b/tests/wallet_state/test_wallet_state.hpp old mode 100644 new mode 100755 diff --git a/vendor/hidapi/hidapi.h b/vendor/hidapi/hidapi.h old mode 100644 new mode 100755 diff --git a/vendor/hidapi/linux/hid.c b/vendor/hidapi/linux/hid.c old mode 100644 new mode 100755 diff --git a/vendor/hidapi/mac/hid.c b/vendor/hidapi/mac/hid.c old mode 100644 new mode 100755 diff --git a/vendor/hmac/Makefile b/vendor/hmac/Makefile old mode 100644 new mode 100755 diff --git a/vendor/hmac/hmac_sha2.c b/vendor/hmac/hmac_sha2.c old mode 100644 new mode 100755 diff --git a/vendor/hmac/hmac_sha2.h b/vendor/hmac/hmac_sha2.h old mode 100644 new mode 100755 diff --git a/vendor/hmac/sha2.c b/vendor/hmac/sha2.c old mode 100644 new mode 100755 diff --git a/vendor/hmac/sha2.h b/vendor/hmac/sha2.h old mode 100644 new mode 100755 diff --git a/vendor/sqlite/README.md b/vendor/sqlite/README.md old mode 100644 new mode 100755 diff --git a/vendor/sqlite/shell.c b/vendor/sqlite/shell.c old mode 100644 new mode 100755 diff --git a/vendor/sqlite/sqlite3.c b/vendor/sqlite/sqlite3.c old mode 100644 new mode 100755 diff --git a/vendor/sqlite/sqlite3.h b/vendor/sqlite/sqlite3.h old mode 100644 new mode 100755 diff --git a/vendor/sqlite/sqlite3ext.h b/vendor/sqlite/sqlite3ext.h old mode 100644 new mode 100755