diff --git a/.gitignore b/.gitignore index 40c5a53..cea24dc 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,11 @@ debug/ release/ x64/ artifacts/ +docs/website/public .vscode/ +res/libsodium.a res/libsodium/libsodium* +res/libsodium.a src/ui_*.h *.autosave src/precompiled.h.cpp @@ -27,4 +30,4 @@ workspace.code-workspace .DS_Store *.mak *.plist -zcashd \ No newline at end of file +zcashd diff --git a/.travis.yml b/.travis.yml index 9a6d8d6..9ac7330 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,15 +11,17 @@ matrix: before_install: - sudo add-apt-repository ppa:beineri/opt-qt591-trusty -y - sudo apt-get update -qq - - sudo apt-get install qt59base + - sudo apt-get install qt59base qt59websockets - source /opt/qt59/bin/qt59-env.sh script: - qmake -v - clang++ -v - g++-8 -v - - qmake zec-qt-wallet.pro CONFIG+=release -spec linux-g++ - - make CC=gcc-8 CXX=g++-8 -j2 - - make distclean - qmake zec-qt-wallet.pro CONFIG+=release -spec linux-clang - make CC=clang CXX=clang++ -j2 + - make distclean + - qmake zec-qt-wallet.pro CONFIG+=release -spec linux-g++ + - res/libsodium/buildlibsodium.sh + - make CC=gcc-8 CXX=g++-8 -j2 + \ No newline at end of file diff --git a/README.md b/README.md index 2b3febd..c0fe025 100644 --- a/README.md +++ b/README.md @@ -10,14 +10,14 @@ Head over to the releases page and grab the latest installers or binary. https:/ If you are on Debian/Ubuntu, please download the `.deb` package and install it. ``` -sudo dpkg -i linux-deb-zec-qt-wallet-v0.5.7.deb +sudo dpkg -i linux-deb-zec-qt-wallet-v0.6.1.deb sudo apt install -f ``` Or you can download and run the binaries directly. ``` -tar -xvf zec-qt-wallet-v0.5.7.tar.gz -./zec-qt-wallet-v0.5.7/zec-qt-wallet +tar -xvf zec-qt-wallet-v0.6.1.tar.gz +./zec-qt-wallet-v0.6.1/zec-qt-wallet ``` ### Windows diff --git a/application.qrc b/application.qrc index b033129..e7e9b2c 100644 --- a/application.qrc +++ b/application.qrc @@ -15,5 +15,6 @@ res/zec_qt_wallet_es.qm res/zec_qt_wallet_fr.qm res/zec_qt_wallet_pt.qm + res/zec_qt_wallet_it.qm diff --git a/public_key.asc b/public_key.asc new file mode 100644 index 0000000..cda4e1b --- /dev/null +++ b/public_key.asc @@ -0,0 +1,52 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQINBFxYtBoBEACfLqL2YB0pMFk7X7ILBYfakxWnTd8CKCp2EhfSj4cRDFSD5ODj +TfkRTb7Jj7zL3LkGfA5R6ZnK4994JojVfkrDWWZfaZG6Us0cZEwqPiDYli0gc7GG +KMudAorHI6ud/dQzsglJf3mcZ+7GYtrwG69QLM6ZpleAjY8JQ+5k70sn9dEhMUGq +YWe7MBPY5IrHNp14eFiLNY0b+//bxrD32OkW0Xqx3ZEdX/C4NoAw3Zk8k61CRMFC +mBV+GZURhA511Bxy4QIySP8spSl2aW8bvXtwXYniY3C30lTd2Y4L8zWNhtR1+EuB +LBr6m61VMkQ2qckoDFymNI86VEw5LoLlgRC1RsMOfJtlAvdnI/hSqSYwtpnvQ1Vf +oRmWYnfWP+A0Xdqb+FC2n0GtINzh6w3L/+46ydy+u+EgrlPjs+qWilvOF6e0bLxG +y9PI2058ozDeixEwHLg+jxltsQvR9zQNTxbWd49iMcohWIlSe+pokptVv98e8ILm +m/7az7bcyXeqnyPIM+wo5DybrHVNHJwpbicvjQV0pXqllRQYgBabD2JT9u1J8UvU +h/rTKPQaWMa8hDe8rLS/n7axhm8LScvAjjWo4UFyKzFPUKIIQGkzvYyB8VydvHBB +jDFvSt20vuCiR9ugdTVo6n+79ZcbUpv1S1GV19h41/f0U/OD6tXFaNaNswARAQAB +tDthZGl0eWFwazAwIChQR1AgS2V5IGZvciB6ZWMtcXQtd2FsbGV0KSA8emNhc2hA +YWRpdHlhcGsuY29tPokCTgQTAQgAOBYhBMIxctDJVpWR7OyOyw4ekCeVIeu0BQJc +WLQaAhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJEA4ekCeVIeu09rEP/3ef +lQPHz273VhVXte60mqiU2iQWeLq1xRUQ0udeyM3S80uubcS2iR1s+EYr9yFhxI/q +lS33iJcFpKG0Us5UZmk0Vh57zEmzhGUfL6ZRJtS7yRUsmtp0csS+xcSbGh3h9cDw +uvzkPMGPwEhNjLrEutuvPPO1pU8erEllvnYeHrnOe9klzfIuQ8javZlbbc6MUBft +PN/WjNft8OXDYelSizlEJ3vQphxjm4Pb+GBkEMssy76LnWpPj/OKvWkFZGO51QYC +MvLjvBDyFn1o2+TPSKyhsmqd/wwSZ5vSi6oojAmdZsIFOVqQ2sRZIpJFYaWCXfh2 +XMoMXy5PXjaQMC1L3LUKbUggPRo+jbLzLziJ78mQzWhHJaigqRpkdrXT287PBm+F +Vt+NxQYBxzUXSb0C2H+Yq2tbzax49znV+5b4f1xPTvWFDlMzCG1NTuWzUD//nDO+ +RFUvEHHaHD593OBhUHpXKdCcwqHUnZTB1/KmxyXC8GdHYOnRtZQcaaiS7x6Vmosc +gQLbeRhn8EjG4jsMLyzK0inV2Lb+n5wpbsZHZNKacqIAAO1nxI+Y88lO8dJ97bBj +C/L4D2P4PnQ3u4c/50SUFyqV90u7wU5ituu/56Lr+kCX1T3+HfJ6CWHm4gvOLXPv +YkHfOnZN7nuCsZ/Iy9ja/5KXddylqORwCHpeRu5VuQINBFxYtBoBEADAG/VTgFLh +wOffLVU2eEr/+/PGt4DLkDBnJcwQeknxniiqYi7vqueKUYZMFc5AiPGDSgGN4QwH +5aDTjChDHMINcM/IVGqXJPfKRyXjNeJJ+WVAaSs6cmkGNf6tVHf/OKiXO70ETLwS +xOKlrlGPP0+ERL/VN85ulOXBD9lOV/l2n9c8akuwy6gNoqZeEU3D1EipUfFGRuUO +P5RZjCUWlXVTz8UZXAC8UpJ5DJxuwSipIsf95l6OH+NQqCyFDPY5GgUQA6bORUEf +eKkJwuv0XxVVLciDla1+LmIBDyjlK30eLKOzlxTF6zDbvD572L6E2MUuKk1wGQWh +38hvbkZ6hU2zNW+JJibS0bnQG8H8Cin7wWEWcXKvjF3zqL23KRMwduZS15oSxIxN +TcQSuRvkGoP1Zmy46k1eJQXzoIFrjMj1RxcG0j2gFTaX21AHzd561hmpX/9wqxSA +XiW/pkf6/0wF2hL0i337H/8Wq9DmrjeKH/UKT81ApOu4pFSY62ZvQrzlwKpHPeNm +pWuGw0Erxiz/5MqggMdDXIu4NdSaqBfynbWaP9BMeoz+qUfSZp+XSWTD1vrSCdlJ +RMbN0MAA/nVZDoPzPxONnOXxdV8eRJWPFN1g4lWa4KKTNZ85tu15AMWF7837de6L +prY3wYXMrUxpk2/18LWQGqZKCjr+xZuIcQARAQABiQI2BBgBCAAgFiEEwjFy0MlW +lZHs7I7LDh6QJ5Uh67QFAlxYtBoCGwwACgkQDh6QJ5Uh67SF0g/9H6oDmk/J1FS4 +MQwlkY0Iuzu8BtcY0DZaOxK+cw4lu24/hy1T+RKvN8UIklx9ujixhOxJ9759ujkH +sWf9X5wVxXMSDGV8E7C+QapbuXDpmXtbQFHBfb3OulJHV+mn33MdYidq1rJPMvyZ +/aVg+WW8BOcTanDlM5mSoGIYAzV4m82RKLyIgewrYHgnvJDoE8AtOVZVqvQ20+XK +0LXPPCYeJbf3+GW+uOwC+LOnYQCFaUbaGjbJ16W9kK7+Dhb0o3v8CvEOxYc6w+5G +6sFHlZBRBssro/7Y2E10Xk+XqQbutF4jrej0Cs6ZoSDAoWpQfHL7JQGxKsE+T1R6 +ywnQ20/+J18vciV5eOjHi/c0r9DVm4BS0bZBvXk6RVhIt25VDgiv+IHBsDmB+hqE +Y5rVr4jKeCeRITCMX9KmKF18cl4BEtvgycgm3UicIB9uKHuCwxFXJU2v2zaD8vuW +LhdK8sSFOQkc6Yc9XtwUWpZkCdE+M8oFpb8W1uGQAriqa0JL0oQJnD/O9clRojhd +WKBY7r1i1sQRoFuvj5J4aoFPFoI0abp5nLkWnjm1noMqtwZt89WsTBZjEMT+/AsM +VXWIG1yDezS1FzxCa6NGO+Xyp1GSVZvSrIaJ+B53n/eCYJgoQNZUa4Y2krvax8Ag +8/k3fH5u794KFQQ3WbeHVoJ4mXI4RsQ= +=lY99 +-----END PGP PUBLIC KEY BLOCK----- diff --git a/res/SIGNATURES_README b/res/SIGNATURES_README new file mode 100644 index 0000000..4891f05 --- /dev/null +++ b/res/SIGNATURES_README @@ -0,0 +1,13 @@ +This directory contains the hashes and signatures for zec-qt-wallet + +Verify the hashes by running: +sha256sum -c sha256sum-vX.Y.Z.txt + +Verify signatures: +1. First, import the public key (Available on github + at https://github.com/ZcashFoundation/zec-qt-wallet/blob/master/public_key.asc) +gpg --import public_key.asc + +2. Verify signature +gpg --verify + diff --git a/res/connectoverinternetcheckbox.png b/res/connectoverinternetcheckbox.png new file mode 100644 index 0000000..2125854 Binary files /dev/null and b/res/connectoverinternetcheckbox.png differ diff --git a/res/liblibsodium.a b/res/liblibsodium.a new file mode 100644 index 0000000..363c743 Binary files /dev/null and b/res/liblibsodium.a differ diff --git a/res/libsodium.lib b/res/libsodium.lib new file mode 100644 index 0000000..7a93b9d Binary files /dev/null and b/res/libsodium.lib differ diff --git a/res/libsodium/buildlibsodium.sh b/res/libsodium/buildlibsodium.sh new file mode 100755 index 0000000..6c59382 --- /dev/null +++ b/res/libsodium/buildlibsodium.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# First thing to do is see if libsodium.a exists in the res folder. If it does, then there's nothing to do +if [ -f res/libsodium.a ]; then + exit 0 +fi + +echo "Building libsodium" + +# Go into the lib sodium directory +cd res/libsodium +if [ ! -f libsodium-1.0.16.tar.gz ]; then + wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.16.tar.gz +fi + +if [ ! -d libsodium-1.0.16 ]; then + tar xf libsodium-1.0.16.tar.gz +fi + +# Now build it +cd libsodium-1.0.16 +LIBS="" ./configure +make clean +if [[ "$OSTYPE" == "darwin"* ]]; then + make CFLAGS="-mmacosx-version-min=10.11" CPPFLAGS="-mmacosx-version-min=10.11" -j4 +else + make -j4 +fi +cd .. + +# copy the library to the parents's res/ folder +cp libsodium-1.0.16/src/libsodium/.libs/libsodium.a ../ diff --git a/res/libsodiumd.lib b/res/libsodiumd.lib new file mode 100644 index 0000000..98a68f8 Binary files /dev/null and b/res/libsodiumd.lib differ diff --git a/res/wormholeconnect.png b/res/wormholeconnect.png new file mode 100644 index 0000000..ccd478b Binary files /dev/null and b/res/wormholeconnect.png differ diff --git a/res/zec_qt_wallet_de.qm b/res/zec_qt_wallet_de.qm index 7e96a2d..7359977 100644 Binary files a/res/zec_qt_wallet_de.qm and b/res/zec_qt_wallet_de.qm differ diff --git a/res/zec_qt_wallet_de.ts b/res/zec_qt_wallet_de.ts index fd505b8..a9dd659 100644 --- a/res/zec_qt_wallet_de.ts +++ b/res/zec_qt_wallet_de.ts @@ -4,12 +4,12 @@ AddressBookModel - + Label YOUR_TRANSLATION_HERE - + Address YOUR_TRANSLATION_HERE @@ -17,12 +17,12 @@ BalancesTableModel - + Address YOUR_TRANSLATION_HERE - + Amount YOUR_TRANSLATION_HERE @@ -84,7 +84,7 @@ - + Send YOUR_TRANSLATION_HERE @@ -111,23 +111,23 @@ - - - + + + Address YOUR_TRANSLATION_HERE - + Address Book YOUR_TRANSLATION_HERE - - + + Amount YOUR_TRANSLATION_HERE @@ -138,9 +138,9 @@ - - - + + + Memo YOUR_TRANSLATION_HERE @@ -151,530 +151,563 @@ - + Recurring payment + + + + + Every month, starting 12-May-2012, for 6 payments + + + + + Edit Schedule + + + + + Miner Fee YOUR_TRANSLATION_HERE - + 0 YOUR_TRANSLATION_HERE - + Cancel YOUR_TRANSLATION_HERE - + Receive YOUR_TRANSLATION_HERE - + Address Type YOUR_TRANSLATION_HERE - z-Addr(Sapling) - YOUR_TRANSLATION_HERE + YOUR_TRANSLATION_HERE - + t-Addr YOUR_TRANSLATION_HERE - z-Addr(Sprout) - YOUR_TRANSLATION_HERE + YOUR_TRANSLATION_HERE - + New Address YOUR_TRANSLATION_HERE - + Label YOUR_TRANSLATION_HERE - + Update Label YOUR_TRANSLATION_HERE - + Address balance - + Optional YOUR_TRANSLATION_HERE - + Export Private Key YOUR_TRANSLATION_HERE - - Address used + + z-Addr - + + z-Addr(Legacy Sprout) + + + + Transactions YOUR_TRANSLATION_HERE - + zcashd YOUR_TRANSLATION_HERE - + You are currently not mining YOUR_TRANSLATION_HERE - - - - + + + + Loading... YOUR_TRANSLATION_HERE - + Block height YOUR_TRANSLATION_HERE - + Network solution rate YOUR_TRANSLATION_HERE - + Connections YOUR_TRANSLATION_HERE - - - + + + | YOUR_TRANSLATION_HERE - + &File YOUR_TRANSLATION_HERE - + &Help YOUR_TRANSLATION_HERE - + &Apps YOUR_TRANSLATION_HERE - + &Edit YOUR_TRANSLATION_HERE - + E&xit YOUR_TRANSLATION_HERE - + &About YOUR_TRANSLATION_HERE - + &Settings YOUR_TRANSLATION_HERE - + Ctrl+P YOUR_TRANSLATION_HERE - + &Donate YOUR_TRANSLATION_HERE - + Check github.com for &updates YOUR_TRANSLATION_HERE - + Sapling &turnstile YOUR_TRANSLATION_HERE - + Ctrl+A, Ctrl+T YOUR_TRANSLATION_HERE - + &Import private key YOUR_TRANSLATION_HERE - + &Export all private keys YOUR_TRANSLATION_HERE - + &z-board.net YOUR_TRANSLATION_HERE - + Ctrl+A, Ctrl+Z YOUR_TRANSLATION_HERE - + Address &book YOUR_TRANSLATION_HERE - + Ctrl+B YOUR_TRANSLATION_HERE - + &Backup wallet.dat YOUR_TRANSLATION_HERE - - + + Export transactions - + Pay zcash &URI... - + + Connect mobile &app + + + + + Ctrl+M + + + + Tor configuration is available only when running an embedded zcashd. - + Enable Tor - + Connection over Tor has been enabled. To use this feature, you need to restart zec-qt-wallet. - + Disable Tor - + Connection over Tor has been disabled. To fully disconnect from Tor, you need to restart zec-qt-wallet. - + Thanks for supporting zec-qt-wallet! YOUR_TRANSLATION_HERE - + Donate 0.01 YOUR_TRANSLATION_HERE - + to support zec-qt-wallet YOUR_TRANSLATION_HERE - + You are on testnet, your post won't actually appear on z-board.net YOUR_TRANSLATION_HERE - + You need a sapling address with available balance to post YOUR_TRANSLATION_HERE - - + + Computing Tx: YOUR_TRANSLATION_HERE - + The keys were imported. It may take several minutes to rescan the blockchain. Until then, functionality may be limited YOUR_TRANSLATION_HERE - + Private key import rescan finished YOUR_TRANSLATION_HERE - + Error paying zcash URI - + URI should be of the form 'zcash:<addr>?amt=x&memo=y - + Paste Zcash URI - + Could not understand address - + Unknown field in URI: - + Please paste your private keys (z-Addr or t-Addr) here, one per line YOUR_TRANSLATION_HERE - + The keys will be imported into your connected zcashd node YOUR_TRANSLATION_HERE - + Error - + Error exporting transactions, file was not saved - + No wallet.dat YOUR_TRANSLATION_HERE - + Couldn't find the wallet.dat on this computer YOUR_TRANSLATION_HERE - + You need to back it up from the machine zcashd is running on YOUR_TRANSLATION_HERE - + Backup wallet.dat YOUR_TRANSLATION_HERE - + Couldn't backup YOUR_TRANSLATION_HERE - + Couldn't backup the wallet.dat file. YOUR_TRANSLATION_HERE - + You need to back it up manually. YOUR_TRANSLATION_HERE - + These are all the private keys for all the addresses in your wallet YOUR_TRANSLATION_HERE - + Private key for YOUR_TRANSLATION_HERE - + Save File YOUR_TRANSLATION_HERE - + Unable to open file YOUR_TRANSLATION_HERE - - + + Copy address YOUR_TRANSLATION_HERE - - - + + + Copied to clipboard YOUR_TRANSLATION_HERE - + Get private key YOUR_TRANSLATION_HERE - + Shield balance to Sapling YOUR_TRANSLATION_HERE - - + + View on block explorer YOUR_TRANSLATION_HERE - + Migrate to Sapling YOUR_TRANSLATION_HERE - + Copy txid YOUR_TRANSLATION_HERE - + View Memo YOUR_TRANSLATION_HERE - + Reply to - + Created new t-Addr YOUR_TRANSLATION_HERE - + + Creation of new Sprout addresses is deprecated + + + + Address has been previously used - + Address is unused - + Recipient YOUR_TRANSLATION_HERE - + Only z-addresses can have memos YOUR_TRANSLATION_HERE - + Memos can only be used with z-addresses YOUR_TRANSLATION_HERE - + The memo field can only be used with a z-address. YOUR_TRANSLATION_HERE - + doesn't look like a z-address YOUR_TRANSLATION_HERE - + Reply to - + Change from YOUR_TRANSLATION_HERE - + Current balance : - + Balance after this Tx: - + Transaction Error YOUR_TRANSLATION_HERE - + From Address is Invalid YOUR_TRANSLATION_HERE - + Recipient Address YOUR_TRANSLATION_HERE - + is Invalid YOUR_TRANSLATION_HERE - + Amount '%1' is invalid! @@ -693,6 +726,60 @@ doesn't look like a z-address + + MobileAppConnector + + + Connect Mobile App + + + + + Scan this QRCode from your ZecQT Wallet companion app to connect your phone + + + + + QR Code + + + + + Connection String + + + + + Allow connections over the internet via zec-qt-wallet wormhole + + + + + ZecQT Wallet Companion App + + + + + Disconnect + + + + + + TextLabel + + + + + Last seen: + + + + + Connection type: + + + PrivKey @@ -704,27 +791,27 @@ doesn't look like a z-address QObject - + Attempting autoconnect YOUR_TRANSLATION_HERE - + Starting embedded zcashd YOUR_TRANSLATION_HERE - + zcashd is set to run as daemon YOUR_TRANSLATION_HERE - + Waiting for zcashd YOUR_TRANSLATION_HERE - + You have zcashd set to start as a daemon, which can cause problems with zec-qt-wallet .Please remove the following line from your zcash.conf and restart zec-qt-wallet @@ -732,7 +819,7 @@ daemon=1 YOUR_TRANSLATION_HERE - + Couldn't start the embedded zcashd. Please try restarting. @@ -743,249 +830,274 @@ If all else fails, please run zcashd manually. YOUR_TRANSLATION_HERE - + Couldn't connect to zcashd configured in zcash.conf. Not starting embedded zcashd because --no-embedded was passed YOUR_TRANSLATION_HERE - + + Hide Advanced Config + + + + + Show Advanced Config + + + + + Choose data directory + + + + All Downloads Finished Successfully! YOUR_TRANSLATION_HERE - + Couldn't download params. Please check the help site for more info. YOUR_TRANSLATION_HERE - + The process returned YOUR_TRANSLATION_HERE - - + + Downloading YOUR_TRANSLATION_HERE - + more remaining ) YOUR_TRANSLATION_HERE - + MB of YOUR_TRANSLATION_HERE - + MB at YOUR_TRANSLATION_HERE - + Downloading blocks YOUR_TRANSLATION_HERE - + Block height YOUR_TRANSLATION_HERE - + Syncing YOUR_TRANSLATION_HERE - + Connected YOUR_TRANSLATION_HERE - + testnet: YOUR_TRANSLATION_HERE - + Connected to zcashd YOUR_TRANSLATION_HERE - + zcashd has no peer connections - + There was an error connecting to zcashd. The error was YOUR_TRANSLATION_HERE - + + + The transaction with id YOUR_TRANSLATION_HERE - + + + failed. The error was YOUR_TRANSLATION_HERE - + + + failed YOUR_TRANSLATION_HERE - + + + Tx YOUR_TRANSLATION_HERE - + tx computing. This can take several minutes. YOUR_TRANSLATION_HERE - + Update Available - + A new release v%1 is available! You have v%2. Would you like to visit the releases page? - + No updates available - + You already have the latest release v%1 - + Please wait for zec-qt-wallet to exit YOUR_TRANSLATION_HERE - + Waiting for zcashd to exit YOUR_TRANSLATION_HERE - + failed. Please check the help site for more info YOUR_TRANSLATION_HERE - + zcashd error YOUR_TRANSLATION_HERE - + A manual connection was requested, but the settings are not configured. Please set the host/port and user/password in the Edit->Settings menu. YOUR_TRANSLATION_HERE - + Could not connect to zcashd configured in settings. Please set the host/port and user/password in the Edit->Settings menu. YOUR_TRANSLATION_HERE - + Authentication failed. The username / password you specified was not accepted by zcashd. Try changing it in the Edit->Settings menu YOUR_TRANSLATION_HERE - + Your zcashd is starting up. Please wait. YOUR_TRANSLATION_HERE - - + + Connection Error YOUR_TRANSLATION_HERE - - + + + + Transaction Error YOUR_TRANSLATION_HERE - + There was an error sending the transaction. The error was: YOUR_TRANSLATION_HERE - - + + No Connection YOUR_TRANSLATION_HERE - + Pick - + Address Format Error YOUR_TRANSLATION_HERE - + doesn't seem to be a valid Zcash address. YOUR_TRANSLATION_HERE - + Import Address Book - + Unable to open file YOUR_TRANSLATION_HERE - + Address Book Import Done - + Imported %1 new Address book entries - + Copy address YOUR_TRANSLATION_HERE - + Copied to clipboard YOUR_TRANSLATION_HERE - + Delete label YOUR_TRANSLATION_HERE @@ -1006,7 +1118,7 @@ You either have unconfirmed funds or the balance is too low for an automatic mig YOUR_TRANSLATION_HERE - + Computing Tx: YOUR_TRANSLATION_HERE @@ -1030,6 +1142,49 @@ You either have unconfirmed funds or the balance is too low for an automatic mig Amount YOUR_TRANSLATION_HERE + + + Connected directly + + + + + Connected over the internet via zec-qt-wallet wormhole service + + + + + Node is still syncing. + + + + + No sapling or transparent addresses with enough balance to spend. + + + + + RecurringDialog + + + Dialog + + + + + Add + + + + + Edit + + + + + Delete + + Settings @@ -1265,6 +1420,102 @@ You either have unconfirmed funds or the balance is too low for an automatic mig YOUR_TRANSLATION_HERE + + createZcashConf + + + Configure zcash.conf + + + + + Show Advanced Configuration + + + + + Your zcash node will be configured for you automatically + + + + + Use custom datadir + + + + + Please choose a directory to store your wallet.dat and blockchain + + + + + Choose directory + + + + + Connect over Tor + + + + + Please note that you'll need to already have a Tor service configured on port 9050 + + + + + newRecurringDialog + + + Edit Schedule + + + + + Schedule + + + + + Payment Description + + + + + TextLabel + + + + + From + YOUR_TRANSLATION_HERE + + + + Number of payments + + + + + Amount + YOUR_TRANSLATION_HERE + + + + Next Payment + + + + + To + YOUR_TRANSLATION_HERE + + + + Memo + YOUR_TRANSLATION_HERE + + zboard diff --git a/res/zec_qt_wallet_es.qm b/res/zec_qt_wallet_es.qm index d5fbd28..e41ee1c 100644 Binary files a/res/zec_qt_wallet_es.qm and b/res/zec_qt_wallet_es.qm differ diff --git a/res/zec_qt_wallet_es.ts b/res/zec_qt_wallet_es.ts index d7f69e0..c14d888 100644 --- a/res/zec_qt_wallet_es.ts +++ b/res/zec_qt_wallet_es.ts @@ -4,12 +4,12 @@ AddressBookModel - + Label Etiqueta - + Address Dirección @@ -17,12 +17,12 @@ BalancesTableModel - + Address Dirección - + Amount Monto @@ -84,7 +84,7 @@ - + Send Envía @@ -111,23 +111,23 @@ - - - + + + Address Dirección - + Address Book Directorio - - + + Amount Monto @@ -138,9 +138,9 @@ - - - + + + Memo Memo @@ -151,530 +151,563 @@ - + Recurring payment + + + + + Every month, starting 12-May-2012, for 6 payments + + + + + Edit Schedule + + + + + Miner Fee Cuota Minera - + 0 0 - + Cancel Cancelar - + Receive Recibir - + Address Type Tipo De Dirección - z-Addr(Sapling) - z-Addr(Sapling) + z-Addr(Sapling) - + t-Addr t-Addr - z-Addr(Sprout) - z-Addr(Sprout) + z-Addr(Sprout) - + New Address Nueva Dirección - + Label Etiqueta - + Update Label Actualizar Etiqueta - + Address balance - + Optional Opcional - + Export Private Key Exportar Clave Privada - - Address used + + z-Addr - + + z-Addr(Legacy Sprout) + + + + Transactions Transacciones - + zcashd zcashd - + You are currently not mining Actualmente no estas minando - - - - + + + + Loading... Cargando... - + Block height Altura del bloque - + Network solution rate Rapidez de solución de red - + Connections Conexiones - - - + + + | | - + &File &Archivo - + &Help &Ayuda - + &Apps &Apps - + &Edit &Editar - + E&xit Salir - + &About &Acerca de - + &Settings &Configuración - + Ctrl+P Ctrl+P - + &Donate &Donar - + Check github.com for &updates Consulte las actualizaciones en github.com - + Sapling &turnstile Sapling &turnstile - + Ctrl+A, Ctrl+T Ctrl+A, Ctrl+T - + &Import private key Importar clave privada - + &Export all private keys Exportar todas las claves privadas - + &z-board.net z-board.net - + Ctrl+A, Ctrl+Z Ctrl+A, Ctrl+Z - + Address &book Directorio - + Ctrl+B Ctrl+B - + &Backup wallet.dat Respaldar wallet.dat - - + + Export transactions - + Pay zcash &URI... - + + Connect mobile &app + + + + + Ctrl+M + + + + Tor configuration is available only when running an embedded zcashd. - + Enable Tor - + Connection over Tor has been enabled. To use this feature, you need to restart zec-qt-wallet. - + Disable Tor - + Connection over Tor has been disabled. To fully disconnect from Tor, you need to restart zec-qt-wallet. - + Thanks for supporting zec-qt-wallet! Gracias por apoyar zec-qt-wallet! - + Donate 0.01 Donar 0.01 - + to support zec-qt-wallet para apoyar zec-qt-wallet - + You are on testnet, your post won't actually appear on z-board.net Estas en testnet, tu publicación no aparecerá en z-board.net - + You need a sapling address with available balance to post Necesitas una dirección Sapling con saldo disponible para publicar - - + + Computing Tx: Calculando Tx: - + The keys were imported. It may take several minutes to rescan the blockchain. Until then, functionality may be limited Las claves fueron importadas. Puede que se demore varios minutos en volver a escanear el blockchain. Hasta entonces, la funcionalidad puede ser limitada. - + Private key import rescan finished Importación de clave privada re-escaneada finalizada - + Error paying zcash URI - + URI should be of the form 'zcash:<addr>?amt=x&memo=y - + Paste Zcash URI - + Could not understand address - + Unknown field in URI: - + Please paste your private keys (z-Addr or t-Addr) here, one per line Por favor pegue sus claves privadas (z-Addr o t-Addr) aqui, una por línea - + The keys will be imported into your connected zcashd node Las claves serán importadas en su nodo zcashd conectado - + Error - + Error exporting transactions, file was not saved - + No wallet.dat Sin wallet.dat - + Couldn't find the wallet.dat on this computer No se pudo encontrar wallet.dat en esta computadora - + You need to back it up from the machine zcashd is running on Necesitas hacer una copia de seguridad de la computadora en la que se está ejecutando zcashd - + Backup wallet.dat Respaldar wallet.dat - + Couldn't backup No se pudo hacer una copia de seguridad - + Couldn't backup the wallet.dat file. No se pudo hacer copia de seguridad de wallet.dat - + You need to back it up manually. Necesitas hacer una copia de seguridad manualmente. - + These are all the private keys for all the addresses in your wallet Estas son todas las claves privadas para todas las direcciones en tu billetera - + Private key for Clave privada para - + Save File Guardar Archivo - + Unable to open file No es posible abrir el archivo - - + + Copy address Copiar dirección - - - + + + Copied to clipboard Copiado al portapapeles - + Get private key Obtener clave privada - + Shield balance to Sapling Proteger saldo a Sapling - - + + View on block explorer Ver en el explorador de bloques - + Migrate to Sapling Migrar a Sapling - + Copy txid Copiar txid - + View Memo Ver Memo - + Reply to - + Created new t-Addr Nuevo dirección t-Addr creada - + + Creation of new Sprout addresses is deprecated + + + + Address has been previously used - + Address is unused - + Recipient Destinatario - + Only z-addresses can have memos Solo las direcciones z-Addr pueden tener memos - + Memos can only be used with z-addresses Los memos solo se pueden usar con direcciones z-Addr - + The memo field can only be used with a z-address. El campo memo solo puede ser usado con una direccion z-Addr - + doesn't look like a z-address no parece una direccion z-Addr - + Reply to - + Change from Cambiar de - + Current balance : - + Balance after this Tx: - + Transaction Error Error de Transacción - + From Address is Invalid Dirección de envio inválida - + Recipient Address Dirección de Destinatario - + is Invalid es Inválida - + Amount '%1' is invalid! @@ -693,6 +726,60 @@ doesn't look like a z-address + + MobileAppConnector + + + Connect Mobile App + + + + + Scan this QRCode from your ZecQT Wallet companion app to connect your phone + + + + + QR Code + + + + + Connection String + + + + + Allow connections over the internet via zec-qt-wallet wormhole + + + + + ZecQT Wallet Companion App + + + + + Disconnect + + + + + + TextLabel + + + + + Last seen: + + + + + Connection type: + + + PrivKey @@ -704,161 +791,184 @@ doesn't look like a z-address QObject - - + + No Connection Sin Conexión - + Downloading blocks Descargando Bloques - + Block height Altura del bloque - + Syncing Sincronizando - + Connected Conectando - + testnet: testnet: - + Connected to zcashd Conectando a zcashd - + zcashd has no peer connections - + There was an error connecting to zcashd. The error was Hubo un error al conectar con zcashd. El error fue - + + + The transaction with id La transacción con id - + + + failed. The error was falló. El error fue - + + + Tx Tx - + + + failed falló - + tx computing. This can take several minutes. tx computando. Esto puede tomar varios minutos. - + Update Available - + A new release v%1 is available! You have v%2. Would you like to visit the releases page? - + No updates available - + You already have the latest release v%1 - + Please wait for zec-qt-wallet to exit Por favor, espere que zec-qt-wallet salga - + Waiting for zcashd to exit Esperando que zcashd salga - + Attempting autoconnect Intentando de autoconectarse - + Starting embedded zcashd Iniciando zcashd incorporado - + zcashd is set to run as daemon zcashd está configurado para ejecutarse como demonio - + Waiting for zcashd Esperando zcashd - + + Hide Advanced Config + + + + + Show Advanced Config + + + + + Choose data directory + + + + All Downloads Finished Successfully! Todas Las Descargas Terminaron Exitosamente! - + Couldn't download params. Please check the help site for more info. No se pudieron descargar los parámetros. Por favor, consulta el sitio de ayuda para mayor información. - - + + Downloading Descargando - + more remaining ) faltan )) - + MB of MB de - + MB at MB a - + A manual connection was requested, but the settings are not configured. Please set the host/port and user/password in the Edit->Settings menu. @@ -867,7 +977,7 @@ Please set the host/port and user/password in the Edit->Settings menu. - + Could not connect to zcashd configured in settings. Please set the host/port and user/password in the Edit->Settings menu. @@ -877,18 +987,20 @@ Por favor, especificar el host/puerta y usario/contraseña en el menú Editar-&g - - + + + + Transaction Error Error De Transacción - + failed. Please check the help site for more info falló. Por favor, consulte el sitio de ayuda para más información - + You have zcashd set to start as a daemon, which can cause problems with zec-qt-wallet .Please remove the following line from your zcash.conf and restart zec-qt-wallet @@ -898,7 +1010,7 @@ Por favor, eliminar la siguente linea de zcashd.conf y reinicia zec-qt-wallet daemon=1 - + Couldn't start the embedded zcashd. Please try restarting. @@ -914,12 +1026,12 @@ Si todo falla, por favor ejecutar zcashd manualmente. - + The process returned El proceso devuelto - + Couldn't connect to zcashd configured in zcash.conf. Not starting embedded zcashd because --no-embedded was passed @@ -928,28 +1040,28 @@ Not starting embedded zcashd because --no-embedded was passed No iniciaré zcashd incorporado porque la opcion --no-embedded fue dada. - + zcashd error error de zcashd - + Authentication failed. The username / password you specified was not accepted by zcashd. Try changing it in the Edit->Settings menu Autenticación fallida. El usario/contraseña que epecificó no fue aceptado por zcashd. Intenta cambiarlo en el menu Editar->Configuración. - + Your zcashd is starting up. Please wait. Tu zcashd se está iniciando. Por favor espera. - - + + Connection Error Error de conexión - + There was an error sending the transaction. The error was: Hubo un error al enviar la transacción. El error fue: @@ -972,7 +1084,7 @@ El saldo es insuficiente para una migración automática. - + Computing Tx: Calculando Tx: @@ -997,55 +1109,98 @@ El saldo es insuficiente para una migración automática. Monto - + Pick - + Address Format Error Error en el formato de la dirección. - + doesn't seem to be a valid Zcash address. no parece ser una dirección Zcash válida - + Import Address Book - + Unable to open file No es posible abrir el archivo - + Address Book Import Done - + Imported %1 new Address book entries - + Copy address Copiar dirección - + Copied to clipboard Copiado al portapapeles - + Delete label Eliminar etiqueta + + + Connected directly + + + + + Connected over the internet via zec-qt-wallet wormhole service + + + + + Node is still syncing. + + + + + No sapling or transparent addresses with enough balance to spend. + + + + + RecurringDialog + + + Dialog + + + + + Add + + + + + Edit + + + + + Delete + + Settings @@ -1281,6 +1436,102 @@ El saldo es insuficiente para una migración automática. Estás utilizando una tarifa personalizada. Como las tarifas son transparentes estás perdiendo algo de privacidad. Por favor, solo haz esto si sabes lo que estás haciendo! + + createZcashConf + + + Configure zcash.conf + + + + + Show Advanced Configuration + + + + + Your zcash node will be configured for you automatically + + + + + Use custom datadir + + + + + Please choose a directory to store your wallet.dat and blockchain + + + + + Choose directory + + + + + Connect over Tor + + + + + Please note that you'll need to already have a Tor service configured on port 9050 + + + + + newRecurringDialog + + + Edit Schedule + + + + + Schedule + + + + + Payment Description + + + + + TextLabel + + + + + From + Desde + + + + Number of payments + + + + + Amount + Monto + + + + Next Payment + + + + + To + A + + + + Memo + Memo + + zboard diff --git a/res/zec_qt_wallet_fr.qm b/res/zec_qt_wallet_fr.qm index 0b575d8..e8314a8 100644 Binary files a/res/zec_qt_wallet_fr.qm and b/res/zec_qt_wallet_fr.qm differ diff --git a/res/zec_qt_wallet_fr.ts b/res/zec_qt_wallet_fr.ts index 2d9bfbf..eb808c3 100644 --- a/res/zec_qt_wallet_fr.ts +++ b/res/zec_qt_wallet_fr.ts @@ -4,12 +4,12 @@ AddressBookModel - + Label Etiquette - + Address Adresse @@ -17,12 +17,12 @@ BalancesTableModel - + Address Adresse - + Amount Montant @@ -84,7 +84,7 @@ - + Send Envoyer @@ -111,23 +111,23 @@ - - - + + + Address Adresse - + Address Book Carnet d'adresses - - + + Amount Montant @@ -138,9 +138,9 @@ - - - + + + Memo Mémo @@ -151,533 +151,570 @@ - + Recurring payment + + + + + Every month, starting 12-May-2012, for 6 payments + + + + + Edit Schedule + + + + + Miner Fee I replaced this with "transaction fee" which sounds much better in French.. I hope it's correct too.. Frais de transaction - + 0 0 - + Cancel Annuler - + Receive Recevoir - + Address Type Type d'adresse - z-Addr(Sapling) - Adresse-z(Sapling) + Adresse-z(Sapling) - + t-Addr Adresse-t - z-Addr(Sprout) - Adresse-z(Sprout) + Adresse-z(Sprout) - + New Address Nouvelle Adresse - + Label Etiquette - + Update Label Mettre à jour l'étiquette - + Address balance Solde de l'adresse - + Optional Optionnel - + Export Private Key Exporter la clef privée - Address used - Adresse utilisée + Adresse utilisée + + + + z-Addr + + + + + z-Addr(Legacy Sprout) + - + Transactions Transactions - + zcashd zcashd - + You are currently not mining Vous ne minez pas à présent - - - - + + + + Loading... Chargement... - + Block height Hauteur de block - + Network solution rate Taux de solution du réseau - + Connections Connections - - - + + + | | - + &File &Fichier - + &Help &Aide - + &Apps &Applications - + &Edit &Edition - + E&xit Q&uiter - + &About &À propos - + &Settings &Préférences - + Ctrl+P Ctrl+P - + &Donate &Faire un don - + Check github.com for &updates Vérifier &github.com pour des mises à jour - + Sapling &turnstile Sapling &turnstile - + Ctrl+A, Ctrl+T Ctrl+A, Ctrl+T - + &Import private key &Importer une clef privée - + &Export all private keys &Exporter toutes les clefs privées - + &z-board.net &z-board.net - + Ctrl+A, Ctrl+Z Ctrl+A, Ctrl+Z - + Address &book Carnet &d'adresse - + Ctrl+B Ctrl+B - + &Backup wallet.dat &Sauvegarder "wallet.dat" - - + + Export transactions Exporter les transactions - + Pay zcash &URI... PAyer une URI zcash - + + Connect mobile &app + + + + + Ctrl+M + + + + Tor configuration is available only when running an embedded zcashd. La configuration de Tor est disponible uniquement lors de l'exécution du processus zcashd intégré. - + Enable Tor Activer Tor - + Connection over Tor has been enabled. To use this feature, you need to restart zec-qt-wallet. La connection via Tor est activée. Afin d'utiliser cette fonctionnalité, veuillez redémarer zec-qt-wallet. - + Disable Tor Désactiver Tor - + Connection over Tor has been disabled. To fully disconnect from Tor, you need to restart zec-qt-wallet. La connection via Tor a été désactivée. Afin de complètement se déconnecter de Tor, vous devez redémarrer zec-qt-wallet. - + Thanks for supporting zec-qt-wallet! Merci de supporter zec-qt-wallet ! - + Donate 0.01 Donner 0.01 - + to support zec-qt-wallet pour supporter zec-qt-wallet - + You are on testnet, your post won't actually appear on z-board.net Vous êtes connecté au réseau de test. Votre message n'apparaîtra donc pas sur z-board.net - + You need a sapling address with available balance to post Vous avez besoin d'une adresse de type Sapling avec un solde suffisant pour pouvoir poster - - + + Computing Tx: Calcul de la transaction en cours: - + The keys were imported. It may take several minutes to rescan the blockchain. Until then, functionality may be limited Les clefs ont été importées. Cela peut prendre quelque minutes pour rescanner la blockchain. Durant cette période, les fonctionnalités peuvent être limitées - + Private key import rescan finished Rescan de l'import de la clef privée achevé - + Error paying zcash URI Erreur lors du payement du URI zcash - + URI should be of the form 'zcash:<addr>?amt=x&memo=y - Le format URI doit être comme suit: 'zcash:<addr>?amt=x&memo=y< + Le format URI doit être comme suit: 'zcash:<addr>?amt=x&memo=y - + Paste Zcash URI Coller le URI Zcash - + Could not understand address Adresse non valide - + Unknown field in URI: Champ inconnu dans le URI - + Please paste your private keys (z-Addr or t-Addr) here, one per line Veuillez coller votre clef privée (Adresse-z ou Adresse-t) ici. Une clef par ligne - + The keys will be imported into your connected zcashd node Les clef seront importées dans votre noeud zcashd connecté - + Error Erreur - + Error exporting transactions, file was not saved Erreur lors de l'exportation des transactions. Le fichier n'a pas été sauvegardé. - + No wallet.dat Pas de fichier "wallet.dat" - + Couldn't find the wallet.dat on this computer Impossible de trouver le fichier "wallet.dat" sur cet ordinateur - + You need to back it up from the machine zcashd is running on Vous devez effectuer la sauvegarde depuis la machine sur laquelle zcashd est en cours d'exécution - + Backup wallet.dat Sauvegarder wallet.dat - + Couldn't backup La sauvegarde n'a pas pu être effectuée - + Couldn't backup the wallet.dat file. Impossible de sauvegarder le fichier "wallet.dat". - + You need to back it up manually. Vous devez le sauvegarder manuellement. - + These are all the private keys for all the addresses in your wallet Ce sont toutes les clés privées pour toutes les adresses de votre portefeuille - + Private key for Clef privée pour - + Save File Sauvegarder le fichier - + Unable to open file mpossible d'ouvrir le fichier - - + + Copy address Copier l'adresse - - - + + + Copied to clipboard Copié dans le presse-papier - + Get private key Obtenir la clef privée - + Shield balance to Sapling Rendre privé le solde vers Sapling - - + + View on block explorer Voir dans l'explorateur de block - + Migrate to Sapling Migrer vers Sapling - + Copy txid Copier l'ID de transaction - + View Memo Voir le mémo - + Reply to Répondre à - + Created new t-Addr Nouvelle Adresse-t créée - + + Creation of new Sprout addresses is deprecated + + + + Address has been previously used L'adresse a été utilisée précédemment. - + Address is unused L'adresse est inutilisée. - + Recipient Destinataire - + Only z-addresses can have memos Seules les Adresses-z peuvent avoir un mémo - + Memos can only be used with z-addresses Les mémos peuvent seulement être utilisés avec des Adresses-z - + The memo field can only be used with a z-address. Le champs mémo ne peut uniquement être utilisé avec une adresse-z. - + doesn't look like a z-address Cette adresse ne semble pas être de type adresse-z - + Reply to Répondre à - + Change from Changer de - + Current balance : Solde actuel : - + Balance after this Tx: Solde après cette Tx: - + Transaction Error Erreur de transaction - + From Address is Invalid L'adresse de l'émetteur est invalide - + Recipient Address Adresse du destinataire - + is Invalid est invalide - + Amount '%1' is invalid! Le montant '%1' est invalide. @@ -696,6 +733,60 @@ Cette adresse ne semble pas être de type adresse-z Inclure l'adresse de réponse + + MobileAppConnector + + + Connect Mobile App + + + + + Scan this QRCode from your ZecQT Wallet companion app to connect your phone + + + + + QR Code + + + + + Connection String + + + + + Allow connections over the internet via zec-qt-wallet wormhole + + + + + ZecQT Wallet Companion App + + + + + Disconnect + + + + + + TextLabel + + + + + Last seen: + + + + + Connection type: + + + PrivKey @@ -707,27 +798,27 @@ Cette adresse ne semble pas être de type adresse-z QObject - + Attempting autoconnect Tentative de connection automatique - + Starting embedded zcashd Démarrage de zcashd intégré - + zcashd is set to run as daemon zcashd est configuré pour s'exécuter en tant que démon - + Waiting for zcashd En attente de zcashd - + You have zcashd set to start as a daemon, which can cause problems with zec-qt-wallet .Please remove the following line from your zcash.conf and restart zec-qt-wallet @@ -738,7 +829,7 @@ daemon=1 daemon=1 - + Couldn't start the embedded zcashd. Please try restarting. @@ -755,157 +846,180 @@ Si vous avez précédemment démarré zcashd avec des arguments, vous devrez peu Si tout échoue, exécutez zcashd manuellement. - + Couldn't connect to zcashd configured in zcash.conf. Not starting embedded zcashd because --no-embedded was passed Le démarrage de zcashd n'a pas eu lieu car l'argument --no-embedded a été utilisé au lancement - + + Hide Advanced Config + + + + + Show Advanced Config + + + + + Choose data directory + + + + All Downloads Finished Successfully! Tous les téléchargements terminés avec succès ! - + Couldn't download params. Please check the help site for more info. Impossible de télécharger les paramètres. Veuillez vous rendre sur le site d'aide pour plus d'info. - + The process returned Le processus a renvoyé - - + + Downloading Téléchargement en cours - + more remaining ) restant) - + MB of MB de - + MB at MB à - + Downloading blocks Blocs en cours de téléchargement - + Block height Hauteur de bloc - + Syncing Synchronisation - + Connected Connecté - + testnet: réseau test: - + Connected to zcashd Connecté à zcashd - + zcashd has no peer connections - zcashd n'a aucune connexion à un pair + zcashd n'a aucune connexion à un pair - + There was an error connecting to zcashd. The error was Une erreur est survenue lors de la connection à zcashd. L'erreur est - + + + The transaction with id La transaction avec ID - + + + failed. The error was a échoué. L'erreur était - + + + failed a échoué - + + + Tx Tx - + tx computing. This can take several minutes. tx en cours de calcul. Ceci peut prendre quelques minutes. - + Update Available MàJ disponible - + A new release v%1 is available! You have v%2. Would you like to visit the releases page? Voulez-vous visiter la page des nouvelles versions ? - + No updates available Pas de MàJ disponible - + You already have the latest release v%1 - Vous utilisez déjà la dernière version v%1 + Vous utilisez déjà la dernière version v%1 - + Please wait for zec-qt-wallet to exit Veuillez patienter. Fermeture de zec-qt-wallet en cours - + Waiting for zcashd to exit Attente de la fermeture de zcashd - + failed. Please check the help site for more info a échoué. Veuillez vous rendre sur le site d'aide pour plus d'info - + zcashd error erreur zcashd - + A manual connection was requested, but the settings are not configured. Please set the host/port and user/password in the Edit->Settings menu. @@ -914,7 +1028,7 @@ Please set the host/port and user/password in the Edit->Settings menu. - + Could not connect to zcashd configured in settings. Please set the host/port and user/password in the Edit->Settings menu. @@ -923,85 +1037,87 @@ Please set the host/port and user/password in the Edit->Settings menu. - + Authentication failed. The username / password you specified was not accepted by zcashd. Try changing it in the Edit->Settings menu Authentification échouée. Le nom d'utilisateur / mot de passe que vous avez spécifié n'a pas été accepté par zcashd. Essayez de le changer dans le menu Edition-> Préférences - + Your zcashd is starting up. Please wait. Votre zcashd est en cours de démarrage. Veuillez patienter. - - + + Connection Error Erreur de connection - - + + + + Transaction Error Erreur de transaction - + There was an error sending the transaction. The error was: Une erreur est survenue en envoyant la transaction. L'erreur est: - - + + No Connection Pas de connection - + Pick Choisir - + Address Format Error Erreur de format d'adresse - + doesn't seem to be a valid Zcash address. ne semble pas être une adresse Zcash valide. - + Import Address Book Importer le carnet d'adresses - + Unable to open file Impossible d'ouvrir le fichier - + Address Book Import Done Import du carnet d'adresses terminé - + Imported %1 new Address book entries %1 nouvelle(s) entrée(s) importée(s) dans le carnet d'adresses. - + Copy address Copier l'adresse - + Copied to clipboard Copiée dans le presse papier - + Delete label Effacer l'étiquette @@ -1023,7 +1139,7 @@ You either have unconfirmed funds or the balance is too low for an automatic mig Vous avez soit des fonds non confirmés soit le solde est trop petit pour une migration automatique. - + Computing Tx: Calcul de Tx en cours: @@ -1047,6 +1163,49 @@ Vous avez soit des fonds non confirmés soit le solde est trop petit pour une mi Amount Montant + + + Connected directly + + + + + Connected over the internet via zec-qt-wallet wormhole service + + + + + Node is still syncing. + + + + + No sapling or transparent addresses with enough balance to spend. + + + + + RecurringDialog + + + Dialog + + + + + Add + + + + + Edit + + + + + Delete + + Settings @@ -1269,7 +1428,7 @@ Vous avez soit des fonds non confirmés soit le solde est trop petit pour une mi zcashd doesn't seem to have any peers. You might not be connected to the internet, so this Transaction might not work. - zcashd semble n'avoir aucune connexion à un autre pair. Comme vous n'êtes peut-être pas connecté à Internet, cette transaction pourrait ne pas fonctionner. + zcashd semble n'avoir aucune connexion à un autre pair. Comme vous n'êtes peut-être pas connecté à Internet, cette transaction pourrait ne pas fonctionner. @@ -1282,6 +1441,102 @@ Vous avez soit des fonds non confirmés soit le solde est trop petit pour une mi Vous appliquez des frais personnalisés. Comme les frais sont transparents, vous diminuez votre caractère privé. Veuillez seulement utiliser ceci si vous êtes sûr de ce que vous faites ! + + createZcashConf + + + Configure zcash.conf + + + + + Show Advanced Configuration + + + + + Your zcash node will be configured for you automatically + + + + + Use custom datadir + + + + + Please choose a directory to store your wallet.dat and blockchain + + + + + Choose directory + + + + + Connect over Tor + + + + + Please note that you'll need to already have a Tor service configured on port 9050 + + + + + newRecurringDialog + + + Edit Schedule + + + + + Schedule + + + + + Payment Description + + + + + TextLabel + + + + + From + De + + + + Number of payments + + + + + Amount + Montant + + + + Next Payment + + + + + To + À + + + + Memo + Mémo + + zboard diff --git a/res/zec_qt_wallet_it.qm b/res/zec_qt_wallet_it.qm new file mode 100644 index 0000000..aa47a74 Binary files /dev/null and b/res/zec_qt_wallet_it.qm differ diff --git a/res/zec_qt_wallet_it.ts b/res/zec_qt_wallet_it.ts new file mode 100644 index 0000000..11d55f9 --- /dev/null +++ b/res/zec_qt_wallet_it.ts @@ -0,0 +1,1595 @@ + + + + + AddressBookModel + + + Label + Etichetta + + + + Address + Indirizzo + + + + BalancesTableModel + + + Address + Indirizzo + + + + Amount + Saldo + + + + ConnectionDialog + + + zec-qt-wallet + zec-qt-wallet + + + + Starting Up + Avvio in corso + + + + MainWindow + + + zec-qt-wallet + zec-qt-wallet + + + + Balance + check + Saldo + + + + Summary + Riepilogo + + + + Shielded + meglio tenerla in EN + Shielded + + + + Transparent + Trasparente + + + + Total + Totale + + + + Some transactions are not yet confirmed + Rilevate transazioni non ancora confermate + + + + Address Balances + Saldo degli indirizzi + + + + + Send + Invia + + + + From + Da + + + + Address Balance + check + Saldo Indirizzo + + + + Send To + Inviare a + + + + Recipient + Destinatario + + + + + + + + Address + Indirizzo + + + + + Address Book + Rubrica + + + + + + + Amount + check + Importo + + + + Max Available + Invia tutto + + + + + + + Memo + Memo + + + + Add Recipient + Aggiungi alla rubrica + + + + Recurring payment + + + + + Every month, starting 12-May-2012, for 6 payments + + + + + Edit Schedule + + + + + + Miner Fee + Commissioni di rete + + + + 0 + 0 + + + + Cancel + Annulla + + + + Receive + Ricevi + + + + Address Type + Tipo Indirizzo + + + z-Addr(Sapling) + z-Addr(Sapling) + + + + t-Addr + t-Addr (Trasparente) + + + z-Addr(Sprout) + z-Addr(Legacy Sprout) + + + + z-Addr + + + + + z-Addr(Legacy Sprout) + + + + + New Address + Crea Indirizzo + + + + Label + Etichetta + + + + Update Label + Aggiorna etichetta + + + + Address balance + + + + + Optional + Opzionale + + + + Export Private Key + Esporta la chiave privata + + + + Transactions + Transazioni + + + + zcashd + zcashd + + + + You are currently not mining + Al momento non stai minando + + + + + + + Loading... + Caricamento... + + + + Block height + check + Ultimo blocco trovato + + + + Network solution rate + check + Potenza di calcolo Network + + + + Connections + Connessioni attive + + + + + + | + | + + + + &File + &File + + + + &Help + &Aiuto + + + + &Apps + &Apps + + + + &Edit + &Modifica + + + + E&xit + &Esci + + + + &About + &About + + + + &Settings + &Impostazioni + + + + Ctrl+P + Ctrl+P + + + + &Donate + &Dona + + + + Check github.com for &updates + Controllo nuovi &aggiornamenti + + + + Sapling &turnstile + Sapling &turnstile + + + + Ctrl+A, Ctrl+T + Ctrl+A, Ctrl+T + + + + &Import private key + &Importa chiave privata + + + + &Export all private keys + &Esporta tutte le chiavi private + + + + &z-board.net + &z-board.net + + + + Ctrl+A, Ctrl+Z + Ctrl+A, Ctrl+Z + + + + Address &book + check + Rubrica &Contatti + + + + Ctrl+B + Ctrl+B + + + + &Backup wallet.dat + &Backup wallet.dat + + + + + Export transactions + + + + + Pay zcash &URI... + + + + + Connect mobile &app + + + + + Ctrl+M + + + + + Thanks for supporting zec-qt-wallet! + Grazie per il tuo supporto a zec-qt-wallet! + + + + Donate 0.01 + Dona 0.01 + + + + to support zec-qt-wallet + per supportare zec-qt-wallet + + + + You are on testnet, your post won't actually appear on z-board.net + Sei nella testnet, i tuoi post non appariranno realmente su z-board.net + + + + You need a sapling address with available balance to post + Hai bisogno di un indirizzo Sapling con saldo per postare + + + + + Computing Tx: + Computazione Transazione: + + + + The keys were imported. It may take several minutes to rescan the blockchain. Until then, functionality may be limited + Le chiavi sono state importate. Potrebbero essere necessari alcuni minuti per eseguire nuovamente la scansione della blockchain. Fino ad allora, le funzionalità potrebbero essere limitate + + + + Private key import rescan finished + L'importazione delle chiavi private è stata completata + + + + Tor configuration is available only when running an embedded zcashd. + + + + + Enable Tor + + + + + Connection over Tor has been enabled. To use this feature, you need to restart zec-qt-wallet. + + + + + Disable Tor + + + + + Connection over Tor has been disabled. To fully disconnect from Tor, you need to restart zec-qt-wallet. + + + + + Error paying zcash URI + + + + + URI should be of the form 'zcash:<addr>?amt=x&memo=y + + + + + Paste Zcash URI + + + + + Could not understand address + + + + + Unknown field in URI: + + + + + Please paste your private keys (z-Addr or t-Addr) here, one per line + Si prega di incollare le chiavi private (z-Addr or t-Addr) qui, una per volta + + + + The keys will be imported into your connected zcashd node + check + Le chiavi saranno importate nel tuo nodo zcashd + + + + Error + + + + + Error exporting transactions, file was not saved + + + + + No wallet.dat + Nessun wallet.dat + + + + Couldn't find the wallet.dat on this computer + Impossibile trovare il wallet.dat su questo computer + + + + You need to back it up from the machine zcashd is running on + È necessario eseguire il backup dalla macchina su cui zcashd è in esecuzione + + + + Backup wallet.dat + Backup wallet.dat + + + + Couldn't backup + Impossibile eseguire il backup + + + + Couldn't backup the wallet.dat file. + Impossibile eseguire il backup del file wallet.dat. + + + + You need to back it up manually. + Devi eseguire il backup manualmente. + + + + These are all the private keys for all the addresses in your wallet + Queste sono le chiavi private per tutti gli indirizzi nel tuo portafoglio + + + + Private key for + Chiave privata per + + + + Save File + Salva File + + + + Unable to open file + Impossibile aprire il file + + + + + Copy address + Copia indirizzo + + + + + + Copied to clipboard + Copiato negli appunti + + + + Get private key + Ottieni una chiave privata + + + + Shield balance to Sapling + Trasferisci il saldo su un indirizzo shielded Sapling + + + + + View on block explorer + Guarda sul block-explorer + + + + Migrate to Sapling + Migra a Sapling + + + + Copy txid + Copia txid + + + + View Memo + Visualizza memo + + + + Reply to + + + + + Created new t-Addr + Crea nuovo t-Addr + + + + Creation of new Sprout addresses is deprecated + + + + + Address has been previously used + + + + + Address is unused + + + + + Recipient + Destinatario + + + + Only z-addresses can have memos + Solo gli indirizzi shielded (z-address) possono avere le memo + + + + Memos can only be used with z-addresses + Le memos possono essere utilizzate solo con z-addresses (Shielded) + + + + The memo field can only be used with a z-address. + + Il campo memo può essere utilizzato solo con z-address (Shielded) + + + + +doesn't look like a z-address + Non sembra uno z-address (Shielded) + + + + Reply to + + + + + Change from + Controllare se opportuno inserire Mittente + Cambiare da + + + + Current balance : + + + + + Balance after this Tx: + + + + + Transaction Error + Errore di transazione + + + + From Address is Invalid + Check + L'indirizzo selezionato non è valido + + + + Recipient Address + Indirizzo Destinatario + + + + is Invalid + non valido + + + + Amount '%1' is invalid! + + + + + MemoDialog + + + + Memo + Memo + + + + Include Reply Address + + + + + MobileAppConnector + + + Connect Mobile App + + + + + Scan this QRCode from your ZecQT Wallet companion app to connect your phone + + + + + QR Code + + + + + Connection String + + + + + Allow connections over the internet via zec-qt-wallet wormhole + + + + + ZecQT Wallet Companion App + + + + + Disconnect + + + + + + TextLabel + + + + + Last seen: + + + + + Connection type: + + + + + PrivKey + + + Private Key + Chiave Privata + + + + QObject + + + Attempting autoconnect + Tentativo di connessione automatica + + + + Starting embedded zcashd + check + Avvio demone zcashd + + + + zcashd is set to run as daemon + zcashd è impostato per essere eseguito come un demone + + + + Waiting for zcashd + In attesa di zcashd + + + + You have zcashd set to start as a daemon, which can cause problems with zec-qt-wallet + +.Please remove the following line from your zcash.conf and restart zec-qt-wallet +daemon=1 + Hai zcashd impostato per l'avvio come daemon, che può causare problemi con zec-qt-wallet + YOUR_TRANSLATION_HERE + + + + Couldn't start the embedded zcashd. + +Please try restarting. + +If you previously started zcashd with custom arguments, you might need to reset zcash.conf. + +If all else fails, please run zcashd manually. + check + Impossibile avviare zcashd integrato +Per favore prova a riavviare. +Se hai precedentemente avviato zcashd con parametri personalizzati, potresti dover reimpostare lo zcash.conf +Se tutto il resto fallisce, si prega di eseguire manualmente zcashd. + + + + Couldn't connect to zcashd configured in zcash.conf. + +Not starting embedded zcashd because --no-embedded was passed + Check + Impossibile connettersi a zcashd come configurato nello zcash.conf. +Non è stato avviato zcashd integrato perché è stato passato il comando --no-embedded + + + + Hide Advanced Config + + + + + Show Advanced Config + + + + + Choose data directory + + + + + All Downloads Finished Successfully! + Tutti i download sono terminati con successo! + + + + Couldn't download params. Please check the help site for more info. + Impossibile scaricare i parametri. Si prega di controllare il sito di aiuto per maggiori informazioni. + + + + The process returned + check + Il processo ha ritornato + + + + + Downloading + Downlaoding + + + + more remaining ) + rimanenti ) + + + + MB of + MB di + + + + MB at + MB a + + + + Downloading blocks + Scaricando i blocchi + + + + Block height + Altezza ultimo blocco + + + + Syncing + Sincronizzazione in corso + + + + Connected + Connesso + + + + testnet: + testnet: + + + + Connected to zcashd + Connesso a zcashd + + + + zcashd has no peer connections + + + + + There was an error connecting to zcashd. The error was + Si è verificato un errore durante la connessione a zcashd. L'errore era + + + + + + The transaction with id + La transazione con id + + + + + + failed. The error was + fallito. l'errore era + + + + + + failed + fallito + + + + + + Tx + Tx + + + + tx computing. This can take several minutes. + computazione Tx. Questo può richiedere diversi minuti. + + + + Update Available + + + + + A new release v%1 is available! You have v%2. + +Would you like to visit the releases page? + + + + + No updates available + + + + + You already have the latest release v%1 + + + + + Please wait for zec-qt-wallet to exit + controllare, senza contesto potrebbe voler dire "attendere zec qt wallet per uscire" o altro, non ho contesto + Si prega di attendere che zec-qt-wallet finisca la procedura di uscita + + + + Waiting for zcashd to exit + vedi appunto precedente + Attendere l'uscita di zcashd + + + + failed. Please check the help site for more info + fallito. Per favore controlllare il sito di aiuto per maggior informazioni + + + + zcashd error + zcashd errore + + + + A manual connection was requested, but the settings are not configured. + +Please set the host/port and user/password in the Edit->Settings menu. + È stata richiesta una connessione manuale, ma le impostazioni non sono state configurate. +Impostare host/porta e utente/password nel menu Modifica-> Impostazioni. + + + + Could not connect to zcashd configured in settings. + +Please set the host/port and user/password in the Edit->Settings menu. + Impossibile connettersi a zcashd configurato nelle impostazioni. + +Impostare host/porta e utente/password nel menu Modifica-> Impostazioni. + + + + Authentication failed. The username / password you specified was not accepted by zcashd. Try changing it in the Edit->Settings menu + Autenticazione fallita. Il nome utente/password che hai specificato non sono stati accettati da zcashd. Prova a cambiarlo nel menu Modifica-> Impostazioni + + + + Your zcashd is starting up. Please wait. + Il tuo zcashd si sta avviando. Attendere prego. + + + + + Connection Error + Errore di Connessione + + + + + + + Transaction Error + Errore di transazione + + + + There was an error sending the transaction. The error was: + Si è verificato un errore durante l'invio della transazione. L'errore era: + + + + + No Connection + Nessuna connessione + + + + Pick + + + + + Address Format Error + Errore nel formato dell'indirizzo + + + + doesn't seem to be a valid Zcash address. + Non sembra un indirizzo Zcash Valido. + + + + Import Address Book + + + + + Unable to open file + Impossibile aprire il file + + + + Address Book Import Done + + + + + Imported %1 new Address book entries + + + + + Copy address + Copia indirizzo + + + + Copied to clipboard + Copiato negli appunti + + + + Delete label + elimina l'etichetta + + + + Tx submitted (right click to copy) txid: + Tx inviato (clic destro per copiare) txid: + + + + Locked funds + Fondi bloccati + + + + Could not initiate migration. +You either have unconfirmed funds or the balance is too low for an automatic migration. + Impossibile avviare la migrazione. +Avete fondi non confermati o il saldo è troppo basso per una migrazione automatica. + + + + Computing Tx: + Computing Tx: + + + + Type + Tipo + + + + Address + Indirizzo + + + + Date/Time + Data/Ora + + + + Amount + Importo + + + + Connected directly + + + + + Connected over the internet via zec-qt-wallet wormhole service + + + + + Node is still syncing. + + + + + No sapling or transparent addresses with enough balance to spend. + + + + + RecurringDialog + + + Dialog + + + + + Add + + + + + Edit + + + + + Delete + + + + + Settings + + + Settings + Impostazioni + + + + zcashd connection + Connessione zcashd + + + + Host + Host + + + + Port + Porta + + + + RPC Username + RPC Username + + + + RPC Password + RPC Password + + + + Options + Opzioni + + + + Connect to the Tor network via SOCKS proxy running on 127.0.0.1:9050. Please note that you'll have to install and run the Tor service externally. + + + + + Shielded transactions are saved locally and shown in the transactions tab. If you uncheck this, shielded transactions will not appear in the transactions tab. + Le transazioni Shielded vengono salvate localmente e visualizzate nella scheda delle transazioni. Se deselezioni questa opzione, le transazioni Shielded non verranno visualizzate nella scheda delle transazioni. + + + + Connect via Tor + + + + + Clear History + Cancellare la cronologia + + + + Remember shielded transactions + Ricorda le transazioni Shielded + + + + Allow custom fees + commissioni? Va bene? + Consenti commissioni personalizzate + + + + Allow overriding the default fees when sending transactions. Enabling this option may compromise your privacy since fees are transparent. + Consentire di ignorare le commissioni di default quando si inviano transazioni. L'attivazione di questa opzione potrebbe compromettere la tua privacy in quanto le commissioni sono trasparenti. + + + + Normally, change from t-Addresses goes to another t-Address. Checking this option will send the change to your shielded sapling address instead. Check this option to increase your privacy. + Normalmente, il passaggio da t-Addresses passa a un altro t-Address. Selezionando questa opzione invierai invece la transazione di resto al tuo indirizzo Shielded Sapling. Seleziona questa opzione per aumentare la tua privacy. + + + + Shield change from t-Addresses to your sapling address + check + Cambia l'indirizzo Shielded da t-Addresses al tuo indirizzo Sapling + + + + Turnstile + + + + Turnstile Migration + Turnstile Migration + + + + Migrate over + Migrazione terminata + + + + From + da + + + + <html><head/><body><p>Funds from Sprout z-Addresses (which start with &quot;zc&quot;) need to be moved to the upgraded Sapling z-Addresses (which start with &quot;zs&quot;). The funds cannot be moved directly, but need to be sent through intermediate &quot;transparent&quot; addresses in privacy-preserving way.</p><p>This migration can be done automatically for you.</p></body></html> + <html><head/><body><p>I fondi da indirizzo Shielded Sprout (che inizia con &quot;zc&quot;) DEVONO essere trasferiti manualmente in un indirizzo Shielded Sapling (che inizia con &quot;zs&quot;). i fondi non possono essere trasferiti direttamente, ma devono essere inviati tramite un indirizzo&quot;Trasparente&quot; intermedio, in modo che sia preservata la privacy.</p><p>La migrazione può essere effettuata in modo automatico</p></body></html> + + + + To + a + + + + Balance + Saldo + + + + Miner Fees + Commissioni Miner + + + + Total Balance + Bilancio Finale + + + + TurnstileProgress + + + Turnstile Migration Progress + Turnstile Migration Progress + + + + From + Da + + + + To + A + + + + Please ensure you have your wallet.dat backed up! + Assicurati di aver eseguito il backup del tuo wallet.dat! + + + + Next Transaction in 4 hours + Prossima transazione in 4 ore + + + + Migration Progress + Avanzamento della migrazione + + + + about + + + About + About + + + + addressBook + + + Address Book + Rubrica + + + + Add New Address + Aggiungi Nuovo Indirizzo + + + + Address (z-Addr or t-Addr) + Indirizzo (z-Addr or t-Addr) + + + + Label + Etichetta + + + + Add to Address Book + Aggiungi a Rubrica + + + + Import Address Book + + + + + confirm + + + Confirm Transaction + Conferma Transazione + + + + From + Da + + + + To + A + + + + zcashd doesn't seem to have any peers. You might not be connected to the internet, so this Transaction might not work. + + + + + You are sending a transaction while your node is still syncing. This may not work. + Stai inviando una transazione mentre il tuo nodo si sta ancora sincronizzando. Potrebbe non funzionare. + + + + You are using a custom fee. Since fees are transparent, you are giving up some privacy. Please use this only if you know what you are doing! + Stai utilizzando delle commissioni personalizzate. Dato che le che le commissioni sono trasparenti, stai rinunciando alla privacy. Si prega di usare questo solo se consapevoli di ciò che si sta facendo! + + + + createZcashConf + + + Configure zcash.conf + + + + + Show Advanced Configuration + + + + + Your zcash node will be configured for you automatically + + + + + Use custom datadir + + + + + Please choose a directory to store your wallet.dat and blockchain + + + + + Choose directory + + + + + Connect over Tor + + + + + Please note that you'll need to already have a Tor service configured on port 9050 + + + + + newRecurringDialog + + + Edit Schedule + + + + + Schedule + + + + + Payment Description + + + + + TextLabel + + + + + From + + + + + Number of payments + + + + + Amount + + + + + Next Payment + + + + + To + + + + + Memo + Memo + + + + zboard + + + Post to z-board.net + Posta su z-board.net + + + + Total Fee + Commissioni Totali + + + + Memo + Memo + + + + (optional) + (opzionale) + + + + Send From + Invia Da + + + + Post As: + Posta come: + + + + <html><head/><body><p>ZBoard: Fully anonymous and untraceable chat messages based on the ZCash blockchain. <a href="http://www.z-board.net/"><span style=" text-decoration: underline; color:#0000ff;">http://www.z-board.net/</span></a></p></body></html> + Check, no idea + <html><head/><body><p>ZBoard: messaggi di chat completamente anonimi e non tracciabili basati sulla blockchain di ZCash. <a href="http://www.z-board.net/"><span style=" text-decoration: underline; color:#0000ff;">http://www.z-board.net/</span></a></p></body></html> + + + + Warning + Attenzione + + + + Posting to Board + Pubblicazione sulla Board + + + diff --git a/res/zec_qt_wallet_pt.qm b/res/zec_qt_wallet_pt.qm index 7f7dcea..8ad03f7 100644 Binary files a/res/zec_qt_wallet_pt.qm and b/res/zec_qt_wallet_pt.qm differ diff --git a/res/zec_qt_wallet_pt.ts b/res/zec_qt_wallet_pt.ts index 60cecf2..90b168f 100644 --- a/res/zec_qt_wallet_pt.ts +++ b/res/zec_qt_wallet_pt.ts @@ -4,12 +4,12 @@ AddressBookModel - + Label Etiqueta - + Address Endereço @@ -17,12 +17,12 @@ BalancesTableModel - + Address Endereço - + Amount Quantidade @@ -84,7 +84,7 @@ - + Send Enviar @@ -111,23 +111,23 @@ - - - + + + Address Endereço - + Address Book Agenda - - + + Amount Quantidade @@ -138,9 +138,9 @@ - - - + + + Memo Anexar recado @@ -151,532 +151,565 @@ - + Recurring payment + + + + + Every month, starting 12-May-2012, for 6 payments + + + + + Edit Schedule + + + + + Miner Fee Taxa de mineração - + 0 0 - + Cancel Cancelar - + Receive Receber - + Address Type Tipo de Endereço - z-Addr(Sapling) - z-Addr(Sapling) + z-Addr(Sapling) - + t-Addr t-Addr - z-Addr(Sprout) - z-Addr(Sprout) + z-Addr(Sprout) - + New Address Novo Endereço - + Label Etiqueta - + Update Label Atualizar - + Address balance - + Optional Opcional - + Export Private Key Exportar Chave Privada - - Address used + + z-Addr - + + z-Addr(Legacy Sprout) + + + + Transactions Transações - + zcashd zcashd - + You are currently not mining Você não está minerando atualmente - - - - + + + + Loading... Carregando... - + Block height Altura do Bloco - + Network solution rate Taxa de soluções da rede - + Connections Conexões - - - + + + | | - + &File &Arquivo - + &Help &Ajuda - + &Apps &Aplicações - + &Edit &Editar - + E&xit Sair - + &About &Sobre - + &Settings &Preferências - + Ctrl+P Ctrl+P - + &Donate &Doar - + Check github.com for &updates &Checar github.com por atualizações - + Sapling &turnstile Sapling &turnstile - + Ctrl+A, Ctrl+T Ctrl+A, Ctrl+T - + &Import private key &Importar chave privada - + &Export all private keys &Exportar todas as chaves privadas - + &z-board.net &z-board.net - + Ctrl+A, Ctrl+Z Ctrl+A, Ctrl+Z - + Address &book &Agenda de Endereços - + Ctrl+B Ctrl+B - + &Backup wallet.dat &Salvar wallet.dat - - + + Export transactions - + Pay zcash &URI... - + + Connect mobile &app + + + + + Ctrl+M + + + + Tor configuration is available only when running an embedded zcashd. - + Enable Tor - + Connection over Tor has been enabled. To use this feature, you need to restart zec-qt-wallet. - + Disable Tor - + Connection over Tor has been disabled. To fully disconnect from Tor, you need to restart zec-qt-wallet. - + Thanks for supporting zec-qt-wallet! Obrigado por apoiar a zec-qt-wallet! - + Donate 0.01 Doar 0.01 - + to support zec-qt-wallet para apoiar zec-qt-wallet - + You are on testnet, your post won't actually appear on z-board.net Você está na testnet, seu post não aparecerá no z-board.net - + You need a sapling address with available balance to post Você precisa de um endereço sapling com saldo disponível para postar - - + + Computing Tx: Gerando Tx: - + The keys were imported. It may take several minutes to rescan the blockchain. Until then, functionality may be limited Chaves importadas. Pode demorar alguns minutos para re-escanear a blockchain. Até lá, funcionalidades poderão estar limitadas - + Private key import rescan finished Re-escan de chave privada completo - + Error paying zcash URI - + URI should be of the form 'zcash:<addr>?amt=x&memo=y - + Paste Zcash URI - + Could not understand address - + Unknown field in URI: - + Please paste your private keys (z-Addr or t-Addr) here, one per line Coloque sua(s) chave(s) privadas (z-Addr ou t-Addr) aqui, uma por linha - + The keys will be imported into your connected zcashd node As chaves serão importadas em seu nó zcashd conectado - + Error - + Error exporting transactions, file was not saved - + No wallet.dat Nenhum wallet.data - + Couldn't find the wallet.dat on this computer Não foi localizado o wallet.dat nesse computador - + You need to back it up from the machine zcashd is running on Você precisar salvar a partir da máquina que zcashd está rodando - + Backup wallet.dat Salvar wallet.dat - + Couldn't backup Não foi possível salvar - + Couldn't backup the wallet.dat file. Não foi possível salvar o arquivo wallet.dat. - + You need to back it up manually. Você precisar salvá-lo manualmente. - + These are all the private keys for all the addresses in your wallet YOUR_TRANSLATION_HERE - + Private key for Chave privada para - + Save File Salvar Arquivo - + Unable to open file Não foi possível abrir o arquivo - - + + Copy address Copiar endereço - - - + + + Copied to clipboard Copiado - + Get private key Obter chave privada - + Shield balance to Sapling Blindar saldo para Sapling - - + + View on block explorer Ver no explorador de blocos - + Migrate to Sapling Migrar para Sapling - + Copy txid Copiar txid - + View Memo Ver Recado - + Reply to - + Created new t-Addr Criar novo t-Addr - + + Creation of new Sprout addresses is deprecated + + + + Address has been previously used - + Address is unused - + Recipient Destinatário - + Only z-addresses can have memos Apenas z-Addresses podem conter recados - + Memos can only be used with z-addresses Recados só podem ser anexados com z-Addresses - + The memo field can only be used with a z-address. O campo de recado só pode ser usado junto com z-Addresses. - + doesn't look like a z-address não se parece com um z-Address - + Reply to - + Change from Troco de - + Current balance : - + Balance after this Tx: - + Transaction Error Erro na Transação - + From Address is Invalid Endereço de partida inválido - + Recipient Address Endereço destinatário - + is Invalid é Inválido - + Amount '%1' is invalid! @@ -695,6 +728,60 @@ não se parece com um z-Address + + MobileAppConnector + + + Connect Mobile App + + + + + Scan this QRCode from your ZecQT Wallet companion app to connect your phone + + + + + QR Code + + + + + Connection String + + + + + Allow connections over the internet via zec-qt-wallet wormhole + + + + + ZecQT Wallet Companion App + + + + + Disconnect + + + + + + TextLabel + + + + + Last seen: + + + + + Connection type: + + + PrivKey @@ -706,27 +793,27 @@ não se parece com um z-Address QObject - + Attempting autoconnect Tentando conectar-se automaticamente - + Starting embedded zcashd Iniciando zcashd acoplado - + zcashd is set to run as daemon erro no zcashd - + Waiting for zcashd Esperando pelo zcashd - + You have zcashd set to start as a daemon, which can cause problems with zec-qt-wallet .Please remove the following line from your zcash.conf and restart zec-qt-wallet @@ -736,7 +823,7 @@ daemon=1 daemon=1 - + Couldn't start the embedded zcashd. Please try restarting. @@ -751,7 +838,7 @@ Se você iniciou zcashd anteriormente com parâmetros customizados você pode pr Se ainda assim não der certo, por favor rode zcashd manualmente. - + Couldn't connect to zcashd configured in zcash.conf. Not starting embedded zcashd because --no-embedded was passed @@ -760,150 +847,173 @@ Not starting embedded zcashd because --no-embedded was passed Não iniciando zcashd acoplado porque nenhum foi passado como parâmetro - + + Hide Advanced Config + + + + + Show Advanced Config + + + + + Choose data directory + + + + All Downloads Finished Successfully! Todos os downloads terminaram com sucesso! - + Couldn't download params. Please check the help site for more info. Não foi possível baixar os parâmetros. Por favor, verifique o site de ajuda para mais informações. - + The process returned O processo retornou - - + + Downloading Baixando - + more remaining ) faltando ) - + MB of MB de - + MB at MB a - + Downloading blocks Baixando blocos - + Block height Altura do bloco - + Syncing Sincronizando - + Connected Conectado - + testnet: testnet: - + Connected to zcashd Conectado ao zcashd - + zcashd has no peer connections - + There was an error connecting to zcashd. The error was Ocorreu um erro conectando ao zcashd. O erro foi - + + + The transaction with id A transação com id - + + + failed. The error was falhou. O erro foi - + + + failed falhou - + + + Tx Tx - + tx computing. This can take several minutes. gerando transação. Isso pode levar alguns minutos. - + Update Available - + A new release v%1 is available! You have v%2. Would you like to visit the releases page? - + No updates available - + You already have the latest release v%1 - + Please wait for zec-qt-wallet to exit Por favor, espera zec-qt-wallet finalizar - + Waiting for zcashd to exit Esperando zcashd finalizar - + failed. Please check the help site for more info falhou. Por favor, cheque o site de ajuda para mais informações - + zcashd error erro no zcashd - + A manual connection was requested, but the settings are not configured. Please set the host/port and user/password in the Edit->Settings menu. @@ -912,7 +1022,7 @@ Please set the host/port and user/password in the Edit->Settings menu. - + Could not connect to zcashd configured in settings. Please set the host/port and user/password in the Edit->Settings menu. @@ -921,85 +1031,87 @@ Please set the host/port and user/password in the Edit->Settings menu. - + Authentication failed. The username / password you specified was not accepted by zcashd. Try changing it in the Edit->Settings menu Autenticação falhou. O usuário/senha especificado não foi aceitado pelo zcashd. Tente alterá-los em Editar->Preferências - + Your zcashd is starting up. Please wait. Seu zcashd está iniciando. Por favor aguarde. - - + + Connection Error Erro na Conexão - - + + + + Transaction Error Erro na transação - + There was an error sending the transaction. The error was: Ocorreu um erro enviando a transação. O erro foi: - - + + No Connection Sem Conexão - + Pick - + Address Format Error Erro no Formato do Endereço - + doesn't seem to be a valid Zcash address. não aparenter ser um endereço válido de Zcash. - + Import Address Book - + Unable to open file Não foi possível abrir o arquivo - + Address Book Import Done - + Imported %1 new Address book entries - + Copy address Copiar endereço - + Copied to clipboard Copiado - + Delete label Deletar etiqueta @@ -1021,7 +1133,7 @@ You either have unconfirmed funds or the balance is too low for an automatic mig Você possui fundos não confirmados ou o saldo é muito baixo para uma migração automática. - + Computing Tx: Gerando Tx: @@ -1045,6 +1157,49 @@ Você possui fundos não confirmados ou o saldo é muito baixo para uma migraç Amount Quantidade + + + Connected directly + + + + + Connected over the internet via zec-qt-wallet wormhole service + + + + + Node is still syncing. + + + + + No sapling or transparent addresses with enough balance to spend. + + + + + RecurringDialog + + + Dialog + + + + + Add + + + + + Edit + + + + + Delete + + Settings @@ -1280,6 +1435,102 @@ Você possui fundos não confirmados ou o saldo é muito baixo para uma migraç Você está usando uma taxa customizada. Como as taxas são transparentes, você pode estar comprometendo sua privacidade. Por favor, só use isso se souber o que está fazendo! + + createZcashConf + + + Configure zcash.conf + + + + + Show Advanced Configuration + + + + + Your zcash node will be configured for you automatically + + + + + Use custom datadir + + + + + Please choose a directory to store your wallet.dat and blockchain + + + + + Choose directory + + + + + Connect over Tor + + + + + Please note that you'll need to already have a Tor service configured on port 9050 + + + + + newRecurringDialog + + + Edit Schedule + + + + + Schedule + + + + + Payment Description + + + + + TextLabel + + + + + From + Endereço de partida + + + + Number of payments + + + + + Amount + Quantidade + + + + Next Payment + + + + + To + Para + + + + Memo + + + zboard diff --git a/src/3rdparty/sodium.h b/src/3rdparty/sodium.h new file mode 100644 index 0000000..e7b1af4 --- /dev/null +++ b/src/3rdparty/sodium.h @@ -0,0 +1,70 @@ + +#ifndef sodium_H +#define sodium_H + +#include "sodium/version.h" + +#include "sodium/core.h" +#include "sodium/crypto_aead_aes256gcm.h" +#include "sodium/crypto_aead_chacha20poly1305.h" +#include "sodium/crypto_aead_xchacha20poly1305.h" +#include "sodium/crypto_auth.h" +#include "sodium/crypto_auth_hmacsha256.h" +#include "sodium/crypto_auth_hmacsha512.h" +#include "sodium/crypto_auth_hmacsha512256.h" +#include "sodium/crypto_box.h" +#include "sodium/crypto_box_curve25519xsalsa20poly1305.h" +#include "sodium/crypto_core_hsalsa20.h" +#include "sodium/crypto_core_hchacha20.h" +#include "sodium/crypto_core_salsa20.h" +#include "sodium/crypto_core_salsa2012.h" +#include "sodium/crypto_core_salsa208.h" +#include "sodium/crypto_generichash.h" +#include "sodium/crypto_generichash_blake2b.h" +#include "sodium/crypto_hash.h" +#include "sodium/crypto_hash_sha256.h" +#include "sodium/crypto_hash_sha512.h" +#include "sodium/crypto_kdf.h" +#include "sodium/crypto_kdf_blake2b.h" +#include "sodium/crypto_kx.h" +#include "sodium/crypto_onetimeauth.h" +#include "sodium/crypto_onetimeauth_poly1305.h" +#include "sodium/crypto_pwhash.h" +#include "sodium/crypto_pwhash_argon2i.h" +#include "sodium/crypto_scalarmult.h" +#include "sodium/crypto_scalarmult_curve25519.h" +#include "sodium/crypto_secretbox.h" +#include "sodium/crypto_secretbox_xsalsa20poly1305.h" +#include "sodium/crypto_secretstream_xchacha20poly1305.h" +#include "sodium/crypto_shorthash.h" +#include "sodium/crypto_shorthash_siphash24.h" +#include "sodium/crypto_sign.h" +#include "sodium/crypto_sign_ed25519.h" +#include "sodium/crypto_stream.h" +#include "sodium/crypto_stream_chacha20.h" +#include "sodium/crypto_stream_salsa20.h" +#include "sodium/crypto_stream_xsalsa20.h" +#include "sodium/crypto_verify_16.h" +#include "sodium/crypto_verify_32.h" +#include "sodium/crypto_verify_64.h" +#include "sodium/randombytes.h" +#ifdef __native_client__ +# include "sodium/randombytes_nativeclient.h" +#endif +#include "sodium/randombytes_salsa20_random.h" +#include "sodium/randombytes_sysrandom.h" +#include "sodium/runtime.h" +#include "sodium/utils.h" + +#ifndef SODIUM_LIBRARY_MINIMAL +# include "sodium/crypto_box_curve25519xchacha20poly1305.h" +# include "sodium/crypto_core_ed25519.h" +# include "sodium/crypto_scalarmult_ed25519.h" +# include "sodium/crypto_secretbox_xchacha20poly1305.h" +# include "sodium/crypto_pwhash_scryptsalsa208sha256.h" +# include "sodium/crypto_stream_salsa2012.h" +# include "sodium/crypto_stream_salsa208.h" +# include "sodium/crypto_stream_xchacha20.h" +#endif + +#endif diff --git a/src/3rdparty/sodium/core.h b/src/3rdparty/sodium/core.h new file mode 100644 index 0000000..dd088d2 --- /dev/null +++ b/src/3rdparty/sodium/core.h @@ -0,0 +1,28 @@ + +#ifndef sodium_core_H +#define sodium_core_H + +#include "export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +SODIUM_EXPORT +int sodium_init(void) + __attribute__ ((warn_unused_result)); + +/* ---- */ + +SODIUM_EXPORT +int sodium_set_misuse_handler(void (*handler)(void)); + +SODIUM_EXPORT +void sodium_misuse(void) + __attribute__ ((noreturn)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_aead_aes256gcm.h b/src/3rdparty/sodium/crypto_aead_aes256gcm.h new file mode 100644 index 0000000..46a3800 --- /dev/null +++ b/src/3rdparty/sodium/crypto_aead_aes256gcm.h @@ -0,0 +1,171 @@ +#ifndef crypto_aead_aes256gcm_H +#define crypto_aead_aes256gcm_H + +/* + * WARNING: Despite being the most popular AEAD construction due to its + * use in TLS, safely using AES-GCM in a different context is tricky. + * + * No more than ~ 350 GB of input data should be encrypted with a given key. + * This is for ~ 16 KB messages -- Actual figures vary according to + * message sizes. + * + * In addition, nonces are short and repeated nonces would totally destroy + * the security of this scheme. + * + * Nonces should thus come from atomic counters, which can be difficult to + * set up in a distributed environment. + * + * Unless you absolutely need AES-GCM, use crypto_aead_xchacha20poly1305_ietf_*() + * instead. It doesn't have any of these limitations. + * Or, if you don't need to authenticate additional data, just stick to + * crypto_secretbox(). + */ + +#include +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +SODIUM_EXPORT +int crypto_aead_aes256gcm_is_available(void); + +#define crypto_aead_aes256gcm_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_aead_aes256gcm_keybytes(void); + +#define crypto_aead_aes256gcm_NSECBYTES 0U +SODIUM_EXPORT +size_t crypto_aead_aes256gcm_nsecbytes(void); + +#define crypto_aead_aes256gcm_NPUBBYTES 12U +SODIUM_EXPORT +size_t crypto_aead_aes256gcm_npubbytes(void); + +#define crypto_aead_aes256gcm_ABYTES 16U +SODIUM_EXPORT +size_t crypto_aead_aes256gcm_abytes(void); + +#define crypto_aead_aes256gcm_MESSAGEBYTES_MAX \ + SODIUM_MIN(SODIUM_SIZE_MAX - crypto_aead_aes256gcm_ABYTES, \ + (16ULL * ((1ULL << 32) - 2ULL)) - crypto_aead_aes256gcm_ABYTES) +SODIUM_EXPORT +size_t crypto_aead_aes256gcm_messagebytes_max(void); + +typedef CRYPTO_ALIGN(16) unsigned char crypto_aead_aes256gcm_state[512]; + +SODIUM_EXPORT +size_t crypto_aead_aes256gcm_statebytes(void); + +SODIUM_EXPORT +int crypto_aead_aes256gcm_encrypt(unsigned char *c, + unsigned long long *clen_p, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *ad, + unsigned long long adlen, + const unsigned char *nsec, + const unsigned char *npub, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_aead_aes256gcm_decrypt(unsigned char *m, + unsigned long long *mlen_p, + unsigned char *nsec, + const unsigned char *c, + unsigned long long clen, + const unsigned char *ad, + unsigned long long adlen, + const unsigned char *npub, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_aead_aes256gcm_encrypt_detached(unsigned char *c, + unsigned char *mac, + unsigned long long *maclen_p, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *ad, + unsigned long long adlen, + const unsigned char *nsec, + const unsigned char *npub, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_aead_aes256gcm_decrypt_detached(unsigned char *m, + unsigned char *nsec, + const unsigned char *c, + unsigned long long clen, + const unsigned char *mac, + const unsigned char *ad, + unsigned long long adlen, + const unsigned char *npub, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +/* -- Precomputation interface -- */ + +SODIUM_EXPORT +int crypto_aead_aes256gcm_beforenm(crypto_aead_aes256gcm_state *ctx_, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_aead_aes256gcm_encrypt_afternm(unsigned char *c, + unsigned long long *clen_p, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *ad, + unsigned long long adlen, + const unsigned char *nsec, + const unsigned char *npub, + const crypto_aead_aes256gcm_state *ctx_); + +SODIUM_EXPORT +int crypto_aead_aes256gcm_decrypt_afternm(unsigned char *m, + unsigned long long *mlen_p, + unsigned char *nsec, + const unsigned char *c, + unsigned long long clen, + const unsigned char *ad, + unsigned long long adlen, + const unsigned char *npub, + const crypto_aead_aes256gcm_state *ctx_) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_aead_aes256gcm_encrypt_detached_afternm(unsigned char *c, + unsigned char *mac, + unsigned long long *maclen_p, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *ad, + unsigned long long adlen, + const unsigned char *nsec, + const unsigned char *npub, + const crypto_aead_aes256gcm_state *ctx_); + +SODIUM_EXPORT +int crypto_aead_aes256gcm_decrypt_detached_afternm(unsigned char *m, + unsigned char *nsec, + const unsigned char *c, + unsigned long long clen, + const unsigned char *mac, + const unsigned char *ad, + unsigned long long adlen, + const unsigned char *npub, + const crypto_aead_aes256gcm_state *ctx_) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +void crypto_aead_aes256gcm_keygen(unsigned char k[crypto_aead_aes256gcm_KEYBYTES]); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_aead_chacha20poly1305.h b/src/3rdparty/sodium/crypto_aead_chacha20poly1305.h new file mode 100644 index 0000000..a575ec7 --- /dev/null +++ b/src/3rdparty/sodium/crypto_aead_chacha20poly1305.h @@ -0,0 +1,174 @@ +#ifndef crypto_aead_chacha20poly1305_H +#define crypto_aead_chacha20poly1305_H + +#include +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +/* -- IETF ChaCha20-Poly1305 construction with a 96-bit nonce and a 32-bit internal counter -- */ + +#define crypto_aead_chacha20poly1305_ietf_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_aead_chacha20poly1305_ietf_keybytes(void); + +#define crypto_aead_chacha20poly1305_ietf_NSECBYTES 0U +SODIUM_EXPORT +size_t crypto_aead_chacha20poly1305_ietf_nsecbytes(void); + +#define crypto_aead_chacha20poly1305_ietf_NPUBBYTES 12U + +SODIUM_EXPORT +size_t crypto_aead_chacha20poly1305_ietf_npubbytes(void); + +#define crypto_aead_chacha20poly1305_ietf_ABYTES 16U +SODIUM_EXPORT +size_t crypto_aead_chacha20poly1305_ietf_abytes(void); + +#define crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX \ + SODIUM_MIN(SODIUM_SIZE_MAX - crypto_aead_chacha20poly1305_ietf_ABYTES, \ + (64ULL * (1ULL << 32) - 64ULL) - crypto_aead_chacha20poly1305_ietf_ABYTES) +SODIUM_EXPORT +size_t crypto_aead_chacha20poly1305_ietf_messagebytes_max(void); + +SODIUM_EXPORT +int crypto_aead_chacha20poly1305_ietf_encrypt(unsigned char *c, + unsigned long long *clen_p, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *ad, + unsigned long long adlen, + const unsigned char *nsec, + const unsigned char *npub, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_aead_chacha20poly1305_ietf_decrypt(unsigned char *m, + unsigned long long *mlen_p, + unsigned char *nsec, + const unsigned char *c, + unsigned long long clen, + const unsigned char *ad, + unsigned long long adlen, + const unsigned char *npub, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_aead_chacha20poly1305_ietf_encrypt_detached(unsigned char *c, + unsigned char *mac, + unsigned long long *maclen_p, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *ad, + unsigned long long adlen, + const unsigned char *nsec, + const unsigned char *npub, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_aead_chacha20poly1305_ietf_decrypt_detached(unsigned char *m, + unsigned char *nsec, + const unsigned char *c, + unsigned long long clen, + const unsigned char *mac, + const unsigned char *ad, + unsigned long long adlen, + const unsigned char *npub, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +void crypto_aead_chacha20poly1305_ietf_keygen(unsigned char k[crypto_aead_chacha20poly1305_ietf_KEYBYTES]); + +/* -- Original ChaCha20-Poly1305 construction with a 64-bit nonce and a 64-bit internal counter -- */ + +#define crypto_aead_chacha20poly1305_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_aead_chacha20poly1305_keybytes(void); + +#define crypto_aead_chacha20poly1305_NSECBYTES 0U +SODIUM_EXPORT +size_t crypto_aead_chacha20poly1305_nsecbytes(void); + +#define crypto_aead_chacha20poly1305_NPUBBYTES 8U +SODIUM_EXPORT +size_t crypto_aead_chacha20poly1305_npubbytes(void); + +#define crypto_aead_chacha20poly1305_ABYTES 16U +SODIUM_EXPORT +size_t crypto_aead_chacha20poly1305_abytes(void); + +#define crypto_aead_chacha20poly1305_MESSAGEBYTES_MAX \ + (SODIUM_SIZE_MAX - crypto_aead_chacha20poly1305_ABYTES) +SODIUM_EXPORT +size_t crypto_aead_chacha20poly1305_messagebytes_max(void); + +SODIUM_EXPORT +int crypto_aead_chacha20poly1305_encrypt(unsigned char *c, + unsigned long long *clen_p, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *ad, + unsigned long long adlen, + const unsigned char *nsec, + const unsigned char *npub, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_aead_chacha20poly1305_decrypt(unsigned char *m, + unsigned long long *mlen_p, + unsigned char *nsec, + const unsigned char *c, + unsigned long long clen, + const unsigned char *ad, + unsigned long long adlen, + const unsigned char *npub, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_aead_chacha20poly1305_encrypt_detached(unsigned char *c, + unsigned char *mac, + unsigned long long *maclen_p, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *ad, + unsigned long long adlen, + const unsigned char *nsec, + const unsigned char *npub, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_aead_chacha20poly1305_decrypt_detached(unsigned char *m, + unsigned char *nsec, + const unsigned char *c, + unsigned long long clen, + const unsigned char *mac, + const unsigned char *ad, + unsigned long long adlen, + const unsigned char *npub, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +void crypto_aead_chacha20poly1305_keygen(unsigned char k[crypto_aead_chacha20poly1305_KEYBYTES]); + +/* Aliases */ + +#define crypto_aead_chacha20poly1305_IETF_KEYBYTES crypto_aead_chacha20poly1305_ietf_KEYBYTES +#define crypto_aead_chacha20poly1305_IETF_NSECBYTES crypto_aead_chacha20poly1305_ietf_NSECBYTES +#define crypto_aead_chacha20poly1305_IETF_NPUBBYTES crypto_aead_chacha20poly1305_ietf_NPUBBYTES +#define crypto_aead_chacha20poly1305_IETF_ABYTES crypto_aead_chacha20poly1305_ietf_ABYTES +#define crypto_aead_chacha20poly1305_IETF_MESSAGEBYTES_MAX crypto_aead_chacha20poly1305_ietf_MESSAGEBYTES_MAX + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_aead_xchacha20poly1305.h b/src/3rdparty/sodium/crypto_aead_xchacha20poly1305.h new file mode 100644 index 0000000..99692aa --- /dev/null +++ b/src/3rdparty/sodium/crypto_aead_xchacha20poly1305.h @@ -0,0 +1,97 @@ +#ifndef crypto_aead_xchacha20poly1305_H +#define crypto_aead_xchacha20poly1305_H + +#include +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_aead_xchacha20poly1305_ietf_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_aead_xchacha20poly1305_ietf_keybytes(void); + +#define crypto_aead_xchacha20poly1305_ietf_NSECBYTES 0U +SODIUM_EXPORT +size_t crypto_aead_xchacha20poly1305_ietf_nsecbytes(void); + +#define crypto_aead_xchacha20poly1305_ietf_NPUBBYTES 24U +SODIUM_EXPORT +size_t crypto_aead_xchacha20poly1305_ietf_npubbytes(void); + +#define crypto_aead_xchacha20poly1305_ietf_ABYTES 16U +SODIUM_EXPORT +size_t crypto_aead_xchacha20poly1305_ietf_abytes(void); + +#define crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX \ + (SODIUM_SIZE_MAX - crypto_aead_xchacha20poly1305_ietf_ABYTES) +SODIUM_EXPORT +size_t crypto_aead_xchacha20poly1305_ietf_messagebytes_max(void); + +SODIUM_EXPORT +int crypto_aead_xchacha20poly1305_ietf_encrypt(unsigned char *c, + unsigned long long *clen_p, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *ad, + unsigned long long adlen, + const unsigned char *nsec, + const unsigned char *npub, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_aead_xchacha20poly1305_ietf_decrypt(unsigned char *m, + unsigned long long *mlen_p, + unsigned char *nsec, + const unsigned char *c, + unsigned long long clen, + const unsigned char *ad, + unsigned long long adlen, + const unsigned char *npub, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_aead_xchacha20poly1305_ietf_encrypt_detached(unsigned char *c, + unsigned char *mac, + unsigned long long *maclen_p, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *ad, + unsigned long long adlen, + const unsigned char *nsec, + const unsigned char *npub, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_aead_xchacha20poly1305_ietf_decrypt_detached(unsigned char *m, + unsigned char *nsec, + const unsigned char *c, + unsigned long long clen, + const unsigned char *mac, + const unsigned char *ad, + unsigned long long adlen, + const unsigned char *npub, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +void crypto_aead_xchacha20poly1305_ietf_keygen(unsigned char k[crypto_aead_xchacha20poly1305_ietf_KEYBYTES]); + +/* Aliases */ + +#define crypto_aead_xchacha20poly1305_IETF_KEYBYTES crypto_aead_xchacha20poly1305_ietf_KEYBYTES +#define crypto_aead_xchacha20poly1305_IETF_NSECBYTES crypto_aead_xchacha20poly1305_ietf_NSECBYTES +#define crypto_aead_xchacha20poly1305_IETF_NPUBBYTES crypto_aead_xchacha20poly1305_ietf_NPUBBYTES +#define crypto_aead_xchacha20poly1305_IETF_ABYTES crypto_aead_xchacha20poly1305_ietf_ABYTES +#define crypto_aead_xchacha20poly1305_IETF_MESSAGEBYTES_MAX crypto_aead_xchacha20poly1305_ietf_MESSAGEBYTES_MAX + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_auth.h b/src/3rdparty/sodium/crypto_auth.h new file mode 100644 index 0000000..7174e7b --- /dev/null +++ b/src/3rdparty/sodium/crypto_auth.h @@ -0,0 +1,44 @@ +#ifndef crypto_auth_H +#define crypto_auth_H + +#include + +#include "crypto_auth_hmacsha512256.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_auth_BYTES crypto_auth_hmacsha512256_BYTES +SODIUM_EXPORT +size_t crypto_auth_bytes(void); + +#define crypto_auth_KEYBYTES crypto_auth_hmacsha512256_KEYBYTES +SODIUM_EXPORT +size_t crypto_auth_keybytes(void); + +#define crypto_auth_PRIMITIVE "hmacsha512256" +SODIUM_EXPORT +const char *crypto_auth_primitive(void); + +SODIUM_EXPORT +int crypto_auth(unsigned char *out, const unsigned char *in, + unsigned long long inlen, const unsigned char *k); + +SODIUM_EXPORT +int crypto_auth_verify(const unsigned char *h, const unsigned char *in, + unsigned long long inlen, const unsigned char *k) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +void crypto_auth_keygen(unsigned char k[crypto_auth_KEYBYTES]); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_auth_hmacsha256.h b/src/3rdparty/sodium/crypto_auth_hmacsha256.h new file mode 100644 index 0000000..deec526 --- /dev/null +++ b/src/3rdparty/sodium/crypto_auth_hmacsha256.h @@ -0,0 +1,68 @@ +#ifndef crypto_auth_hmacsha256_H +#define crypto_auth_hmacsha256_H + +#include +#include "crypto_hash_sha256.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_auth_hmacsha256_BYTES 32U +SODIUM_EXPORT +size_t crypto_auth_hmacsha256_bytes(void); + +#define crypto_auth_hmacsha256_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_auth_hmacsha256_keybytes(void); + +SODIUM_EXPORT +int crypto_auth_hmacsha256(unsigned char *out, + const unsigned char *in, + unsigned long long inlen, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_auth_hmacsha256_verify(const unsigned char *h, + const unsigned char *in, + unsigned long long inlen, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +/* ------------------------------------------------------------------------- */ + +typedef struct crypto_auth_hmacsha256_state { + crypto_hash_sha256_state ictx; + crypto_hash_sha256_state octx; +} crypto_auth_hmacsha256_state; + +SODIUM_EXPORT +size_t crypto_auth_hmacsha256_statebytes(void); + +SODIUM_EXPORT +int crypto_auth_hmacsha256_init(crypto_auth_hmacsha256_state *state, + const unsigned char *key, + size_t keylen); + +SODIUM_EXPORT +int crypto_auth_hmacsha256_update(crypto_auth_hmacsha256_state *state, + const unsigned char *in, + unsigned long long inlen); + +SODIUM_EXPORT +int crypto_auth_hmacsha256_final(crypto_auth_hmacsha256_state *state, + unsigned char *out); + + +SODIUM_EXPORT +void crypto_auth_hmacsha256_keygen(unsigned char k[crypto_auth_hmacsha256_KEYBYTES]); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_auth_hmacsha512.h b/src/3rdparty/sodium/crypto_auth_hmacsha512.h new file mode 100644 index 0000000..77a55fb --- /dev/null +++ b/src/3rdparty/sodium/crypto_auth_hmacsha512.h @@ -0,0 +1,67 @@ +#ifndef crypto_auth_hmacsha512_H +#define crypto_auth_hmacsha512_H + +#include +#include "crypto_hash_sha512.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_auth_hmacsha512_BYTES 64U +SODIUM_EXPORT +size_t crypto_auth_hmacsha512_bytes(void); + +#define crypto_auth_hmacsha512_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_auth_hmacsha512_keybytes(void); + +SODIUM_EXPORT +int crypto_auth_hmacsha512(unsigned char *out, + const unsigned char *in, + unsigned long long inlen, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_auth_hmacsha512_verify(const unsigned char *h, + const unsigned char *in, + unsigned long long inlen, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +/* ------------------------------------------------------------------------- */ + +typedef struct crypto_auth_hmacsha512_state { + crypto_hash_sha512_state ictx; + crypto_hash_sha512_state octx; +} crypto_auth_hmacsha512_state; + +SODIUM_EXPORT +size_t crypto_auth_hmacsha512_statebytes(void); + +SODIUM_EXPORT +int crypto_auth_hmacsha512_init(crypto_auth_hmacsha512_state *state, + const unsigned char *key, + size_t keylen); + +SODIUM_EXPORT +int crypto_auth_hmacsha512_update(crypto_auth_hmacsha512_state *state, + const unsigned char *in, + unsigned long long inlen); + +SODIUM_EXPORT +int crypto_auth_hmacsha512_final(crypto_auth_hmacsha512_state *state, + unsigned char *out); + +SODIUM_EXPORT +void crypto_auth_hmacsha512_keygen(unsigned char k[crypto_auth_hmacsha512_KEYBYTES]); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_auth_hmacsha512256.h b/src/3rdparty/sodium/crypto_auth_hmacsha512256.h new file mode 100644 index 0000000..4842f3d --- /dev/null +++ b/src/3rdparty/sodium/crypto_auth_hmacsha512256.h @@ -0,0 +1,62 @@ +#ifndef crypto_auth_hmacsha512256_H +#define crypto_auth_hmacsha512256_H + +#include +#include "crypto_auth_hmacsha512.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_auth_hmacsha512256_BYTES 32U +SODIUM_EXPORT +size_t crypto_auth_hmacsha512256_bytes(void); + +#define crypto_auth_hmacsha512256_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_auth_hmacsha512256_keybytes(void); + +SODIUM_EXPORT +int crypto_auth_hmacsha512256(unsigned char *out, const unsigned char *in, + unsigned long long inlen,const unsigned char *k); + +SODIUM_EXPORT +int crypto_auth_hmacsha512256_verify(const unsigned char *h, + const unsigned char *in, + unsigned long long inlen, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +/* ------------------------------------------------------------------------- */ + +typedef crypto_auth_hmacsha512_state crypto_auth_hmacsha512256_state; + +SODIUM_EXPORT +size_t crypto_auth_hmacsha512256_statebytes(void); + +SODIUM_EXPORT +int crypto_auth_hmacsha512256_init(crypto_auth_hmacsha512256_state *state, + const unsigned char *key, + size_t keylen); + +SODIUM_EXPORT +int crypto_auth_hmacsha512256_update(crypto_auth_hmacsha512256_state *state, + const unsigned char *in, + unsigned long long inlen); + +SODIUM_EXPORT +int crypto_auth_hmacsha512256_final(crypto_auth_hmacsha512256_state *state, + unsigned char *out); + +SODIUM_EXPORT +void crypto_auth_hmacsha512256_keygen(unsigned char k[crypto_auth_hmacsha512256_KEYBYTES]); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_box.h b/src/3rdparty/sodium/crypto_box.h new file mode 100644 index 0000000..99ee19a --- /dev/null +++ b/src/3rdparty/sodium/crypto_box.h @@ -0,0 +1,173 @@ +#ifndef crypto_box_H +#define crypto_box_H + +/* + * THREAD SAFETY: crypto_box_keypair() is thread-safe, + * provided that sodium_init() was called before. + * + * Other functions are always thread-safe. + */ + +#include + +#include "crypto_box_curve25519xsalsa20poly1305.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_box_SEEDBYTES crypto_box_curve25519xsalsa20poly1305_SEEDBYTES +SODIUM_EXPORT +size_t crypto_box_seedbytes(void); + +#define crypto_box_PUBLICKEYBYTES crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES +SODIUM_EXPORT +size_t crypto_box_publickeybytes(void); + +#define crypto_box_SECRETKEYBYTES crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES +SODIUM_EXPORT +size_t crypto_box_secretkeybytes(void); + +#define crypto_box_NONCEBYTES crypto_box_curve25519xsalsa20poly1305_NONCEBYTES +SODIUM_EXPORT +size_t crypto_box_noncebytes(void); + +#define crypto_box_MACBYTES crypto_box_curve25519xsalsa20poly1305_MACBYTES +SODIUM_EXPORT +size_t crypto_box_macbytes(void); + +#define crypto_box_MESSAGEBYTES_MAX crypto_box_curve25519xsalsa20poly1305_MESSAGEBYTES_MAX +SODIUM_EXPORT +size_t crypto_box_messagebytes_max(void); + +#define crypto_box_PRIMITIVE "curve25519xsalsa20poly1305" +SODIUM_EXPORT +const char *crypto_box_primitive(void); + +SODIUM_EXPORT +int crypto_box_seed_keypair(unsigned char *pk, unsigned char *sk, + const unsigned char *seed); + +SODIUM_EXPORT +int crypto_box_keypair(unsigned char *pk, unsigned char *sk); + +SODIUM_EXPORT +int crypto_box_easy(unsigned char *c, const unsigned char *m, + unsigned long long mlen, const unsigned char *n, + const unsigned char *pk, const unsigned char *sk) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_box_open_easy(unsigned char *m, const unsigned char *c, + unsigned long long clen, const unsigned char *n, + const unsigned char *pk, const unsigned char *sk) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_box_detached(unsigned char *c, unsigned char *mac, + const unsigned char *m, unsigned long long mlen, + const unsigned char *n, const unsigned char *pk, + const unsigned char *sk) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_box_open_detached(unsigned char *m, const unsigned char *c, + const unsigned char *mac, + unsigned long long clen, + const unsigned char *n, + const unsigned char *pk, + const unsigned char *sk) + __attribute__ ((warn_unused_result)); + +/* -- Precomputation interface -- */ + +#define crypto_box_BEFORENMBYTES crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES +SODIUM_EXPORT +size_t crypto_box_beforenmbytes(void); + +SODIUM_EXPORT +int crypto_box_beforenm(unsigned char *k, const unsigned char *pk, + const unsigned char *sk) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_box_easy_afternm(unsigned char *c, const unsigned char *m, + unsigned long long mlen, const unsigned char *n, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_box_open_easy_afternm(unsigned char *m, const unsigned char *c, + unsigned long long clen, const unsigned char *n, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_box_detached_afternm(unsigned char *c, unsigned char *mac, + const unsigned char *m, unsigned long long mlen, + const unsigned char *n, const unsigned char *k); + +SODIUM_EXPORT +int crypto_box_open_detached_afternm(unsigned char *m, const unsigned char *c, + const unsigned char *mac, + unsigned long long clen, const unsigned char *n, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +/* -- Ephemeral SK interface -- */ + +#define crypto_box_SEALBYTES (crypto_box_PUBLICKEYBYTES + crypto_box_MACBYTES) +SODIUM_EXPORT +size_t crypto_box_sealbytes(void); + +SODIUM_EXPORT +int crypto_box_seal(unsigned char *c, const unsigned char *m, + unsigned long long mlen, const unsigned char *pk); + +SODIUM_EXPORT +int crypto_box_seal_open(unsigned char *m, const unsigned char *c, + unsigned long long clen, + const unsigned char *pk, const unsigned char *sk) + __attribute__ ((warn_unused_result)); + +/* -- NaCl compatibility interface ; Requires padding -- */ + +#define crypto_box_ZEROBYTES crypto_box_curve25519xsalsa20poly1305_ZEROBYTES +SODIUM_EXPORT +size_t crypto_box_zerobytes(void); + +#define crypto_box_BOXZEROBYTES crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES +SODIUM_EXPORT +size_t crypto_box_boxzerobytes(void); + +SODIUM_EXPORT +int crypto_box(unsigned char *c, const unsigned char *m, + unsigned long long mlen, const unsigned char *n, + const unsigned char *pk, const unsigned char *sk) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_box_open(unsigned char *m, const unsigned char *c, + unsigned long long clen, const unsigned char *n, + const unsigned char *pk, const unsigned char *sk) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_box_afternm(unsigned char *c, const unsigned char *m, + unsigned long long mlen, const unsigned char *n, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_box_open_afternm(unsigned char *m, const unsigned char *c, + unsigned long long clen, const unsigned char *n, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_box_curve25519xchacha20poly1305.h b/src/3rdparty/sodium/crypto_box_curve25519xchacha20poly1305.h new file mode 100644 index 0000000..c1cf756 --- /dev/null +++ b/src/3rdparty/sodium/crypto_box_curve25519xchacha20poly1305.h @@ -0,0 +1,159 @@ + +#ifndef crypto_box_curve25519xchacha20poly1305_H +#define crypto_box_curve25519xchacha20poly1305_H + +#include +#include "crypto_stream_xchacha20.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_box_curve25519xchacha20poly1305_SEEDBYTES 32U +SODIUM_EXPORT +size_t crypto_box_curve25519xchacha20poly1305_seedbytes(void); + +#define crypto_box_curve25519xchacha20poly1305_PUBLICKEYBYTES 32U +SODIUM_EXPORT +size_t crypto_box_curve25519xchacha20poly1305_publickeybytes(void); + +#define crypto_box_curve25519xchacha20poly1305_SECRETKEYBYTES 32U +SODIUM_EXPORT +size_t crypto_box_curve25519xchacha20poly1305_secretkeybytes(void); + +#define crypto_box_curve25519xchacha20poly1305_BEFORENMBYTES 32U +SODIUM_EXPORT +size_t crypto_box_curve25519xchacha20poly1305_beforenmbytes(void); + +#define crypto_box_curve25519xchacha20poly1305_NONCEBYTES 24U +SODIUM_EXPORT +size_t crypto_box_curve25519xchacha20poly1305_noncebytes(void); + +#define crypto_box_curve25519xchacha20poly1305_MACBYTES 16U +SODIUM_EXPORT +size_t crypto_box_curve25519xchacha20poly1305_macbytes(void); + +#define crypto_box_curve25519xchacha20poly1305_MESSAGEBYTES_MAX \ + (crypto_stream_xchacha20_MESSAGEBYTES_MAX - crypto_box_curve25519xchacha20poly1305_MACBYTES) +SODIUM_EXPORT +size_t crypto_box_curve25519xchacha20poly1305_messagebytes_max(void); + +SODIUM_EXPORT +int crypto_box_curve25519xchacha20poly1305_seed_keypair(unsigned char *pk, + unsigned char *sk, + const unsigned char *seed); + +SODIUM_EXPORT +int crypto_box_curve25519xchacha20poly1305_keypair(unsigned char *pk, + unsigned char *sk); + +SODIUM_EXPORT +int crypto_box_curve25519xchacha20poly1305_easy(unsigned char *c, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *n, + const unsigned char *pk, + const unsigned char *sk) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_box_curve25519xchacha20poly1305_open_easy(unsigned char *m, + const unsigned char *c, + unsigned long long clen, + const unsigned char *n, + const unsigned char *pk, + const unsigned char *sk) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_box_curve25519xchacha20poly1305_detached(unsigned char *c, + unsigned char *mac, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *n, + const unsigned char *pk, + const unsigned char *sk) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_box_curve25519xchacha20poly1305_open_detached(unsigned char *m, + const unsigned char *c, + const unsigned char *mac, + unsigned long long clen, + const unsigned char *n, + const unsigned char *pk, + const unsigned char *sk) + __attribute__ ((warn_unused_result)); + +/* -- Precomputation interface -- */ + +SODIUM_EXPORT +int crypto_box_curve25519xchacha20poly1305_beforenm(unsigned char *k, + const unsigned char *pk, + const unsigned char *sk) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_box_curve25519xchacha20poly1305_easy_afternm(unsigned char *c, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *n, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_box_curve25519xchacha20poly1305_open_easy_afternm(unsigned char *m, + const unsigned char *c, + unsigned long long clen, + const unsigned char *n, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_box_curve25519xchacha20poly1305_detached_afternm(unsigned char *c, + unsigned char *mac, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *n, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_box_curve25519xchacha20poly1305_open_detached_afternm(unsigned char *m, + const unsigned char *c, + const unsigned char *mac, + unsigned long long clen, + const unsigned char *n, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +/* -- Ephemeral SK interface -- */ + +#define crypto_box_curve25519xchacha20poly1305_SEALBYTES \ + (crypto_box_curve25519xchacha20poly1305_PUBLICKEYBYTES + \ + crypto_box_curve25519xchacha20poly1305_MACBYTES) + +SODIUM_EXPORT +size_t crypto_box_curve25519xchacha20poly1305_sealbytes(void); + +SODIUM_EXPORT +int crypto_box_curve25519xchacha20poly1305_seal(unsigned char *c, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *pk); + +SODIUM_EXPORT +int crypto_box_curve25519xchacha20poly1305_seal_open(unsigned char *m, + const unsigned char *c, + unsigned long long clen, + const unsigned char *pk, + const unsigned char *sk) + __attribute__ ((warn_unused_result)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_box_curve25519xsalsa20poly1305.h b/src/3rdparty/sodium/crypto_box_curve25519xsalsa20poly1305.h new file mode 100644 index 0000000..c5b15f4 --- /dev/null +++ b/src/3rdparty/sodium/crypto_box_curve25519xsalsa20poly1305.h @@ -0,0 +1,109 @@ +#ifndef crypto_box_curve25519xsalsa20poly1305_H +#define crypto_box_curve25519xsalsa20poly1305_H + +#include +#include "crypto_stream_xsalsa20.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_box_curve25519xsalsa20poly1305_SEEDBYTES 32U +SODIUM_EXPORT +size_t crypto_box_curve25519xsalsa20poly1305_seedbytes(void); + +#define crypto_box_curve25519xsalsa20poly1305_PUBLICKEYBYTES 32U +SODIUM_EXPORT +size_t crypto_box_curve25519xsalsa20poly1305_publickeybytes(void); + +#define crypto_box_curve25519xsalsa20poly1305_SECRETKEYBYTES 32U +SODIUM_EXPORT +size_t crypto_box_curve25519xsalsa20poly1305_secretkeybytes(void); + +#define crypto_box_curve25519xsalsa20poly1305_BEFORENMBYTES 32U +SODIUM_EXPORT +size_t crypto_box_curve25519xsalsa20poly1305_beforenmbytes(void); + +#define crypto_box_curve25519xsalsa20poly1305_NONCEBYTES 24U +SODIUM_EXPORT +size_t crypto_box_curve25519xsalsa20poly1305_noncebytes(void); + +#define crypto_box_curve25519xsalsa20poly1305_MACBYTES 16U +SODIUM_EXPORT +size_t crypto_box_curve25519xsalsa20poly1305_macbytes(void); + +/* Only for the libsodium API - The NaCl compatibility API would require BOXZEROBYTES extra bytes */ +#define crypto_box_curve25519xsalsa20poly1305_MESSAGEBYTES_MAX \ + (crypto_stream_xsalsa20_MESSAGEBYTES_MAX - crypto_box_curve25519xsalsa20poly1305_MACBYTES) +SODIUM_EXPORT +size_t crypto_box_curve25519xsalsa20poly1305_messagebytes_max(void); + +SODIUM_EXPORT +int crypto_box_curve25519xsalsa20poly1305_seed_keypair(unsigned char *pk, + unsigned char *sk, + const unsigned char *seed); + +SODIUM_EXPORT +int crypto_box_curve25519xsalsa20poly1305_keypair(unsigned char *pk, + unsigned char *sk); + +SODIUM_EXPORT +int crypto_box_curve25519xsalsa20poly1305_beforenm(unsigned char *k, + const unsigned char *pk, + const unsigned char *sk) + __attribute__ ((warn_unused_result)); + +/* -- NaCl compatibility interface ; Requires padding -- */ + +#define crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES 16U +SODIUM_EXPORT +size_t crypto_box_curve25519xsalsa20poly1305_boxzerobytes(void); + +#define crypto_box_curve25519xsalsa20poly1305_ZEROBYTES \ + (crypto_box_curve25519xsalsa20poly1305_BOXZEROBYTES + \ + crypto_box_curve25519xsalsa20poly1305_MACBYTES) +SODIUM_EXPORT +size_t crypto_box_curve25519xsalsa20poly1305_zerobytes(void); + +SODIUM_EXPORT +int crypto_box_curve25519xsalsa20poly1305(unsigned char *c, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *n, + const unsigned char *pk, + const unsigned char *sk) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_box_curve25519xsalsa20poly1305_open(unsigned char *m, + const unsigned char *c, + unsigned long long clen, + const unsigned char *n, + const unsigned char *pk, + const unsigned char *sk) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_box_curve25519xsalsa20poly1305_afternm(unsigned char *c, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *n, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_box_curve25519xsalsa20poly1305_open_afternm(unsigned char *m, + const unsigned char *c, + unsigned long long clen, + const unsigned char *n, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_core_ed25519.h b/src/3rdparty/sodium/crypto_core_ed25519.h new file mode 100644 index 0000000..1536294 --- /dev/null +++ b/src/3rdparty/sodium/crypto_core_ed25519.h @@ -0,0 +1,37 @@ +#ifndef crypto_core_ed25519_H +#define crypto_core_ed25519_H + +#include +#include "export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define crypto_core_ed25519_BYTES 32 +SODIUM_EXPORT +size_t crypto_core_ed25519_bytes(void); + +#define crypto_core_ed25519_UNIFORMBYTES 32 +SODIUM_EXPORT +size_t crypto_core_ed25519_uniformbytes(void); + +SODIUM_EXPORT +int crypto_core_ed25519_is_valid_point(const unsigned char *p); + +SODIUM_EXPORT +int crypto_core_ed25519_add(unsigned char *r, + const unsigned char *p, const unsigned char *q); + +SODIUM_EXPORT +int crypto_core_ed25519_sub(unsigned char *r, + const unsigned char *p, const unsigned char *q); + +SODIUM_EXPORT +int crypto_core_ed25519_from_uniform(unsigned char *p, const unsigned char *r); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_core_hchacha20.h b/src/3rdparty/sodium/crypto_core_hchacha20.h new file mode 100644 index 0000000..05e5670 --- /dev/null +++ b/src/3rdparty/sodium/crypto_core_hchacha20.h @@ -0,0 +1,35 @@ +#ifndef crypto_core_hchacha20_H +#define crypto_core_hchacha20_H + +#include +#include "export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define crypto_core_hchacha20_OUTPUTBYTES 32U +SODIUM_EXPORT +size_t crypto_core_hchacha20_outputbytes(void); + +#define crypto_core_hchacha20_INPUTBYTES 16U +SODIUM_EXPORT +size_t crypto_core_hchacha20_inputbytes(void); + +#define crypto_core_hchacha20_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_core_hchacha20_keybytes(void); + +#define crypto_core_hchacha20_CONSTBYTES 16U +SODIUM_EXPORT +size_t crypto_core_hchacha20_constbytes(void); + +SODIUM_EXPORT +int crypto_core_hchacha20(unsigned char *out, const unsigned char *in, + const unsigned char *k, const unsigned char *c); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_core_hsalsa20.h b/src/3rdparty/sodium/crypto_core_hsalsa20.h new file mode 100644 index 0000000..82e475b --- /dev/null +++ b/src/3rdparty/sodium/crypto_core_hsalsa20.h @@ -0,0 +1,35 @@ +#ifndef crypto_core_hsalsa20_H +#define crypto_core_hsalsa20_H + +#include +#include "export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define crypto_core_hsalsa20_OUTPUTBYTES 32U +SODIUM_EXPORT +size_t crypto_core_hsalsa20_outputbytes(void); + +#define crypto_core_hsalsa20_INPUTBYTES 16U +SODIUM_EXPORT +size_t crypto_core_hsalsa20_inputbytes(void); + +#define crypto_core_hsalsa20_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_core_hsalsa20_keybytes(void); + +#define crypto_core_hsalsa20_CONSTBYTES 16U +SODIUM_EXPORT +size_t crypto_core_hsalsa20_constbytes(void); + +SODIUM_EXPORT +int crypto_core_hsalsa20(unsigned char *out, const unsigned char *in, + const unsigned char *k, const unsigned char *c); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_core_salsa20.h b/src/3rdparty/sodium/crypto_core_salsa20.h new file mode 100644 index 0000000..160cc56 --- /dev/null +++ b/src/3rdparty/sodium/crypto_core_salsa20.h @@ -0,0 +1,35 @@ +#ifndef crypto_core_salsa20_H +#define crypto_core_salsa20_H + +#include +#include "export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define crypto_core_salsa20_OUTPUTBYTES 64U +SODIUM_EXPORT +size_t crypto_core_salsa20_outputbytes(void); + +#define crypto_core_salsa20_INPUTBYTES 16U +SODIUM_EXPORT +size_t crypto_core_salsa20_inputbytes(void); + +#define crypto_core_salsa20_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_core_salsa20_keybytes(void); + +#define crypto_core_salsa20_CONSTBYTES 16U +SODIUM_EXPORT +size_t crypto_core_salsa20_constbytes(void); + +SODIUM_EXPORT +int crypto_core_salsa20(unsigned char *out, const unsigned char *in, + const unsigned char *k, const unsigned char *c); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_core_salsa2012.h b/src/3rdparty/sodium/crypto_core_salsa2012.h new file mode 100644 index 0000000..bdd5f9f --- /dev/null +++ b/src/3rdparty/sodium/crypto_core_salsa2012.h @@ -0,0 +1,35 @@ +#ifndef crypto_core_salsa2012_H +#define crypto_core_salsa2012_H + +#include +#include "export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define crypto_core_salsa2012_OUTPUTBYTES 64U +SODIUM_EXPORT +size_t crypto_core_salsa2012_outputbytes(void); + +#define crypto_core_salsa2012_INPUTBYTES 16U +SODIUM_EXPORT +size_t crypto_core_salsa2012_inputbytes(void); + +#define crypto_core_salsa2012_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_core_salsa2012_keybytes(void); + +#define crypto_core_salsa2012_CONSTBYTES 16U +SODIUM_EXPORT +size_t crypto_core_salsa2012_constbytes(void); + +SODIUM_EXPORT +int crypto_core_salsa2012(unsigned char *out, const unsigned char *in, + const unsigned char *k, const unsigned char *c); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_core_salsa208.h b/src/3rdparty/sodium/crypto_core_salsa208.h new file mode 100644 index 0000000..876bda8 --- /dev/null +++ b/src/3rdparty/sodium/crypto_core_salsa208.h @@ -0,0 +1,39 @@ +#ifndef crypto_core_salsa208_H +#define crypto_core_salsa208_H + +#include +#include "export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define crypto_core_salsa208_OUTPUTBYTES 64U +SODIUM_EXPORT +size_t crypto_core_salsa208_outputbytes(void) + __attribute__ ((deprecated)); + +#define crypto_core_salsa208_INPUTBYTES 16U +SODIUM_EXPORT +size_t crypto_core_salsa208_inputbytes(void) + __attribute__ ((deprecated)); + +#define crypto_core_salsa208_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_core_salsa208_keybytes(void) + __attribute__ ((deprecated)); + +#define crypto_core_salsa208_CONSTBYTES 16U +SODIUM_EXPORT +size_t crypto_core_salsa208_constbytes(void) + __attribute__ ((deprecated)); + +SODIUM_EXPORT +int crypto_core_salsa208(unsigned char *out, const unsigned char *in, + const unsigned char *k, const unsigned char *c); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_generichash.h b/src/3rdparty/sodium/crypto_generichash.h new file mode 100644 index 0000000..2398fb9 --- /dev/null +++ b/src/3rdparty/sodium/crypto_generichash.h @@ -0,0 +1,75 @@ +#ifndef crypto_generichash_H +#define crypto_generichash_H + +#include + +#include "crypto_generichash_blake2b.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_generichash_BYTES_MIN crypto_generichash_blake2b_BYTES_MIN +SODIUM_EXPORT +size_t crypto_generichash_bytes_min(void); + +#define crypto_generichash_BYTES_MAX crypto_generichash_blake2b_BYTES_MAX +SODIUM_EXPORT +size_t crypto_generichash_bytes_max(void); + +#define crypto_generichash_BYTES crypto_generichash_blake2b_BYTES +SODIUM_EXPORT +size_t crypto_generichash_bytes(void); + +#define crypto_generichash_KEYBYTES_MIN crypto_generichash_blake2b_KEYBYTES_MIN +SODIUM_EXPORT +size_t crypto_generichash_keybytes_min(void); + +#define crypto_generichash_KEYBYTES_MAX crypto_generichash_blake2b_KEYBYTES_MAX +SODIUM_EXPORT +size_t crypto_generichash_keybytes_max(void); + +#define crypto_generichash_KEYBYTES crypto_generichash_blake2b_KEYBYTES +SODIUM_EXPORT +size_t crypto_generichash_keybytes(void); + +#define crypto_generichash_PRIMITIVE "blake2b" +SODIUM_EXPORT +const char *crypto_generichash_primitive(void); + +typedef crypto_generichash_blake2b_state crypto_generichash_state; + +SODIUM_EXPORT +size_t crypto_generichash_statebytes(void); + +SODIUM_EXPORT +int crypto_generichash(unsigned char *out, size_t outlen, + const unsigned char *in, unsigned long long inlen, + const unsigned char *key, size_t keylen); + +SODIUM_EXPORT +int crypto_generichash_init(crypto_generichash_state *state, + const unsigned char *key, + const size_t keylen, const size_t outlen); + +SODIUM_EXPORT +int crypto_generichash_update(crypto_generichash_state *state, + const unsigned char *in, + unsigned long long inlen); + +SODIUM_EXPORT +int crypto_generichash_final(crypto_generichash_state *state, + unsigned char *out, const size_t outlen); + +SODIUM_EXPORT +void crypto_generichash_keygen(unsigned char k[crypto_generichash_KEYBYTES]); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_generichash_blake2b.h b/src/3rdparty/sodium/crypto_generichash_blake2b.h new file mode 100644 index 0000000..9326a04 --- /dev/null +++ b/src/3rdparty/sodium/crypto_generichash_blake2b.h @@ -0,0 +1,117 @@ +#ifndef crypto_generichash_blake2b_H +#define crypto_generichash_blake2b_H + +#include +#include +#include + +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#if defined(__IBMC__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) +# pragma pack(1) +#else +# pragma pack(push, 1) +#endif + +typedef struct CRYPTO_ALIGN(64) crypto_generichash_blake2b_state { + uint64_t h[8]; + uint64_t t[2]; + uint64_t f[2]; + uint8_t buf[2 * 128]; + size_t buflen; + uint8_t last_node; +} crypto_generichash_blake2b_state; + +#if defined(__IBMC__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) +# pragma pack() +#else +# pragma pack(pop) +#endif + +#define crypto_generichash_blake2b_BYTES_MIN 16U +SODIUM_EXPORT +size_t crypto_generichash_blake2b_bytes_min(void); + +#define crypto_generichash_blake2b_BYTES_MAX 64U +SODIUM_EXPORT +size_t crypto_generichash_blake2b_bytes_max(void); + +#define crypto_generichash_blake2b_BYTES 32U +SODIUM_EXPORT +size_t crypto_generichash_blake2b_bytes(void); + +#define crypto_generichash_blake2b_KEYBYTES_MIN 16U +SODIUM_EXPORT +size_t crypto_generichash_blake2b_keybytes_min(void); + +#define crypto_generichash_blake2b_KEYBYTES_MAX 64U +SODIUM_EXPORT +size_t crypto_generichash_blake2b_keybytes_max(void); + +#define crypto_generichash_blake2b_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_generichash_blake2b_keybytes(void); + +#define crypto_generichash_blake2b_SALTBYTES 16U +SODIUM_EXPORT +size_t crypto_generichash_blake2b_saltbytes(void); + +#define crypto_generichash_blake2b_PERSONALBYTES 16U +SODIUM_EXPORT +size_t crypto_generichash_blake2b_personalbytes(void); + +SODIUM_EXPORT +size_t crypto_generichash_blake2b_statebytes(void); + +SODIUM_EXPORT +int crypto_generichash_blake2b(unsigned char *out, size_t outlen, + const unsigned char *in, + unsigned long long inlen, + const unsigned char *key, size_t keylen); + +SODIUM_EXPORT +int crypto_generichash_blake2b_salt_personal(unsigned char *out, size_t outlen, + const unsigned char *in, + unsigned long long inlen, + const unsigned char *key, + size_t keylen, + const unsigned char *salt, + const unsigned char *personal); + +SODIUM_EXPORT +int crypto_generichash_blake2b_init(crypto_generichash_blake2b_state *state, + const unsigned char *key, + const size_t keylen, const size_t outlen); + +SODIUM_EXPORT +int crypto_generichash_blake2b_init_salt_personal(crypto_generichash_blake2b_state *state, + const unsigned char *key, + const size_t keylen, const size_t outlen, + const unsigned char *salt, + const unsigned char *personal); + +SODIUM_EXPORT +int crypto_generichash_blake2b_update(crypto_generichash_blake2b_state *state, + const unsigned char *in, + unsigned long long inlen); + +SODIUM_EXPORT +int crypto_generichash_blake2b_final(crypto_generichash_blake2b_state *state, + unsigned char *out, + const size_t outlen); + +SODIUM_EXPORT +void crypto_generichash_blake2b_keygen(unsigned char k[crypto_generichash_blake2b_KEYBYTES]); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_hash.h b/src/3rdparty/sodium/crypto_hash.h new file mode 100644 index 0000000..302ed5c --- /dev/null +++ b/src/3rdparty/sodium/crypto_hash.h @@ -0,0 +1,40 @@ +#ifndef crypto_hash_H +#define crypto_hash_H + +/* + * WARNING: Unless you absolutely need to use SHA512 for interoperatibility, + * purposes, you might want to consider crypto_generichash() instead. + * Unlike SHA512, crypto_generichash() is not vulnerable to length + * extension attacks. + */ + +#include + +#include "crypto_hash_sha512.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_hash_BYTES crypto_hash_sha512_BYTES +SODIUM_EXPORT +size_t crypto_hash_bytes(void); + +SODIUM_EXPORT +int crypto_hash(unsigned char *out, const unsigned char *in, + unsigned long long inlen); + +#define crypto_hash_PRIMITIVE "sha512" +SODIUM_EXPORT +const char *crypto_hash_primitive(void) + __attribute__ ((warn_unused_result)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_hash_sha256.h b/src/3rdparty/sodium/crypto_hash_sha256.h new file mode 100644 index 0000000..f64d16e --- /dev/null +++ b/src/3rdparty/sodium/crypto_hash_sha256.h @@ -0,0 +1,57 @@ +#ifndef crypto_hash_sha256_H +#define crypto_hash_sha256_H + +/* + * WARNING: Unless you absolutely need to use SHA256 for interoperatibility, + * purposes, you might want to consider crypto_generichash() instead. + * Unlike SHA256, crypto_generichash() is not vulnerable to length + * extension attacks. + */ + +#include +#include +#include + +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +typedef struct crypto_hash_sha256_state { + uint32_t state[8]; + uint64_t count; + uint8_t buf[64]; +} crypto_hash_sha256_state; + +SODIUM_EXPORT +size_t crypto_hash_sha256_statebytes(void); + +#define crypto_hash_sha256_BYTES 32U +SODIUM_EXPORT +size_t crypto_hash_sha256_bytes(void); + +SODIUM_EXPORT +int crypto_hash_sha256(unsigned char *out, const unsigned char *in, + unsigned long long inlen); + +SODIUM_EXPORT +int crypto_hash_sha256_init(crypto_hash_sha256_state *state); + +SODIUM_EXPORT +int crypto_hash_sha256_update(crypto_hash_sha256_state *state, + const unsigned char *in, + unsigned long long inlen); + +SODIUM_EXPORT +int crypto_hash_sha256_final(crypto_hash_sha256_state *state, + unsigned char *out); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_hash_sha512.h b/src/3rdparty/sodium/crypto_hash_sha512.h new file mode 100644 index 0000000..6b0330f --- /dev/null +++ b/src/3rdparty/sodium/crypto_hash_sha512.h @@ -0,0 +1,57 @@ +#ifndef crypto_hash_sha512_H +#define crypto_hash_sha512_H + +/* + * WARNING: Unless you absolutely need to use SHA512 for interoperatibility, + * purposes, you might want to consider crypto_generichash() instead. + * Unlike SHA512, crypto_generichash() is not vulnerable to length + * extension attacks. + */ + +#include +#include +#include + +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +typedef struct crypto_hash_sha512_state { + uint64_t state[8]; + uint64_t count[2]; + uint8_t buf[128]; +} crypto_hash_sha512_state; + +SODIUM_EXPORT +size_t crypto_hash_sha512_statebytes(void); + +#define crypto_hash_sha512_BYTES 64U +SODIUM_EXPORT +size_t crypto_hash_sha512_bytes(void); + +SODIUM_EXPORT +int crypto_hash_sha512(unsigned char *out, const unsigned char *in, + unsigned long long inlen); + +SODIUM_EXPORT +int crypto_hash_sha512_init(crypto_hash_sha512_state *state); + +SODIUM_EXPORT +int crypto_hash_sha512_update(crypto_hash_sha512_state *state, + const unsigned char *in, + unsigned long long inlen); + +SODIUM_EXPORT +int crypto_hash_sha512_final(crypto_hash_sha512_state *state, + unsigned char *out); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_kdf.h b/src/3rdparty/sodium/crypto_kdf.h new file mode 100644 index 0000000..52e496a --- /dev/null +++ b/src/3rdparty/sodium/crypto_kdf.h @@ -0,0 +1,51 @@ +#ifndef crypto_kdf_H +#define crypto_kdf_H + +#include +#include + +#include "crypto_kdf_blake2b.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_kdf_BYTES_MIN crypto_kdf_blake2b_BYTES_MIN +SODIUM_EXPORT +size_t crypto_kdf_bytes_min(void); + +#define crypto_kdf_BYTES_MAX crypto_kdf_blake2b_BYTES_MAX +SODIUM_EXPORT +size_t crypto_kdf_bytes_max(void); + +#define crypto_kdf_CONTEXTBYTES crypto_kdf_blake2b_CONTEXTBYTES +SODIUM_EXPORT +size_t crypto_kdf_contextbytes(void); + +#define crypto_kdf_KEYBYTES crypto_kdf_blake2b_KEYBYTES +SODIUM_EXPORT +size_t crypto_kdf_keybytes(void); + +#define crypto_kdf_PRIMITIVE "blake2b" +SODIUM_EXPORT +const char *crypto_kdf_primitive(void) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_kdf_derive_from_key(unsigned char *subkey, size_t subkey_len, + uint64_t subkey_id, + const char ctx[crypto_kdf_CONTEXTBYTES], + const unsigned char key[crypto_kdf_KEYBYTES]); + +SODIUM_EXPORT +void crypto_kdf_keygen(unsigned char k[crypto_kdf_KEYBYTES]); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_kdf_blake2b.h b/src/3rdparty/sodium/crypto_kdf_blake2b.h new file mode 100644 index 0000000..5480ebe --- /dev/null +++ b/src/3rdparty/sodium/crypto_kdf_blake2b.h @@ -0,0 +1,42 @@ +#ifndef crypto_kdf_blake2b_H +#define crypto_kdf_blake2b_H + +#include +#include + +#include "crypto_kdf_blake2b.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_kdf_blake2b_BYTES_MIN 16 +SODIUM_EXPORT +size_t crypto_kdf_blake2b_bytes_min(void); + +#define crypto_kdf_blake2b_BYTES_MAX 64 +SODIUM_EXPORT +size_t crypto_kdf_blake2b_bytes_max(void); + +#define crypto_kdf_blake2b_CONTEXTBYTES 8 +SODIUM_EXPORT +size_t crypto_kdf_blake2b_contextbytes(void); + +#define crypto_kdf_blake2b_KEYBYTES 32 +SODIUM_EXPORT +size_t crypto_kdf_blake2b_keybytes(void); + +SODIUM_EXPORT +int crypto_kdf_blake2b_derive_from_key(unsigned char *subkey, size_t subkey_len, + uint64_t subkey_id, + const char ctx[crypto_kdf_blake2b_CONTEXTBYTES], + const unsigned char key[crypto_kdf_blake2b_KEYBYTES]); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_kx.h b/src/3rdparty/sodium/crypto_kx.h new file mode 100644 index 0000000..d1fce90 --- /dev/null +++ b/src/3rdparty/sodium/crypto_kx.h @@ -0,0 +1,64 @@ +#ifndef crypto_kx_H +#define crypto_kx_H + +#include + +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_kx_PUBLICKEYBYTES 32 +SODIUM_EXPORT +size_t crypto_kx_publickeybytes(void); + +#define crypto_kx_SECRETKEYBYTES 32 +SODIUM_EXPORT +size_t crypto_kx_secretkeybytes(void); + +#define crypto_kx_SEEDBYTES 32 +SODIUM_EXPORT +size_t crypto_kx_seedbytes(void); + +#define crypto_kx_SESSIONKEYBYTES 32 +SODIUM_EXPORT +size_t crypto_kx_sessionkeybytes(void); + +#define crypto_kx_PRIMITIVE "x25519blake2b" +SODIUM_EXPORT +const char *crypto_kx_primitive(void); + +SODIUM_EXPORT +int crypto_kx_seed_keypair(unsigned char pk[crypto_kx_PUBLICKEYBYTES], + unsigned char sk[crypto_kx_SECRETKEYBYTES], + const unsigned char seed[crypto_kx_SEEDBYTES]); + +SODIUM_EXPORT +int crypto_kx_keypair(unsigned char pk[crypto_kx_PUBLICKEYBYTES], + unsigned char sk[crypto_kx_SECRETKEYBYTES]); + +SODIUM_EXPORT +int crypto_kx_client_session_keys(unsigned char rx[crypto_kx_SESSIONKEYBYTES], + unsigned char tx[crypto_kx_SESSIONKEYBYTES], + const unsigned char client_pk[crypto_kx_PUBLICKEYBYTES], + const unsigned char client_sk[crypto_kx_SECRETKEYBYTES], + const unsigned char server_pk[crypto_kx_PUBLICKEYBYTES]) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_kx_server_session_keys(unsigned char rx[crypto_kx_SESSIONKEYBYTES], + unsigned char tx[crypto_kx_SESSIONKEYBYTES], + const unsigned char server_pk[crypto_kx_PUBLICKEYBYTES], + const unsigned char server_sk[crypto_kx_SECRETKEYBYTES], + const unsigned char client_pk[crypto_kx_PUBLICKEYBYTES]) + __attribute__ ((warn_unused_result)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_onetimeauth.h b/src/3rdparty/sodium/crypto_onetimeauth.h new file mode 100644 index 0000000..5951c5b --- /dev/null +++ b/src/3rdparty/sodium/crypto_onetimeauth.h @@ -0,0 +1,62 @@ +#ifndef crypto_onetimeauth_H +#define crypto_onetimeauth_H + +#include + +#include "crypto_onetimeauth_poly1305.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +typedef crypto_onetimeauth_poly1305_state crypto_onetimeauth_state; + +SODIUM_EXPORT +size_t crypto_onetimeauth_statebytes(void); + +#define crypto_onetimeauth_BYTES crypto_onetimeauth_poly1305_BYTES +SODIUM_EXPORT +size_t crypto_onetimeauth_bytes(void); + +#define crypto_onetimeauth_KEYBYTES crypto_onetimeauth_poly1305_KEYBYTES +SODIUM_EXPORT +size_t crypto_onetimeauth_keybytes(void); + +#define crypto_onetimeauth_PRIMITIVE "poly1305" +SODIUM_EXPORT +const char *crypto_onetimeauth_primitive(void); + +SODIUM_EXPORT +int crypto_onetimeauth(unsigned char *out, const unsigned char *in, + unsigned long long inlen, const unsigned char *k); + +SODIUM_EXPORT +int crypto_onetimeauth_verify(const unsigned char *h, const unsigned char *in, + unsigned long long inlen, const unsigned char *k) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_onetimeauth_init(crypto_onetimeauth_state *state, + const unsigned char *key); + +SODIUM_EXPORT +int crypto_onetimeauth_update(crypto_onetimeauth_state *state, + const unsigned char *in, + unsigned long long inlen); + +SODIUM_EXPORT +int crypto_onetimeauth_final(crypto_onetimeauth_state *state, + unsigned char *out); + +SODIUM_EXPORT +void crypto_onetimeauth_keygen(unsigned char k[crypto_onetimeauth_KEYBYTES]); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_onetimeauth_poly1305.h b/src/3rdparty/sodium/crypto_onetimeauth_poly1305.h new file mode 100644 index 0000000..4b89c4f --- /dev/null +++ b/src/3rdparty/sodium/crypto_onetimeauth_poly1305.h @@ -0,0 +1,67 @@ +#ifndef crypto_onetimeauth_poly1305_H +#define crypto_onetimeauth_poly1305_H + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#include +#include +#include + +#include + +#include "export.h" + +typedef struct CRYPTO_ALIGN(16) crypto_onetimeauth_poly1305_state { + unsigned char opaque[256]; +} crypto_onetimeauth_poly1305_state; + +SODIUM_EXPORT +size_t crypto_onetimeauth_poly1305_statebytes(void); + +#define crypto_onetimeauth_poly1305_BYTES 16U +SODIUM_EXPORT +size_t crypto_onetimeauth_poly1305_bytes(void); + +#define crypto_onetimeauth_poly1305_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_onetimeauth_poly1305_keybytes(void); + +SODIUM_EXPORT +int crypto_onetimeauth_poly1305(unsigned char *out, + const unsigned char *in, + unsigned long long inlen, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_onetimeauth_poly1305_verify(const unsigned char *h, + const unsigned char *in, + unsigned long long inlen, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_onetimeauth_poly1305_init(crypto_onetimeauth_poly1305_state *state, + const unsigned char *key); + +SODIUM_EXPORT +int crypto_onetimeauth_poly1305_update(crypto_onetimeauth_poly1305_state *state, + const unsigned char *in, + unsigned long long inlen); + +SODIUM_EXPORT +int crypto_onetimeauth_poly1305_final(crypto_onetimeauth_poly1305_state *state, + unsigned char *out); + +SODIUM_EXPORT +void crypto_onetimeauth_poly1305_keygen(unsigned char k[crypto_onetimeauth_poly1305_KEYBYTES]); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_pwhash.h b/src/3rdparty/sodium/crypto_pwhash.h new file mode 100644 index 0000000..2c76461 --- /dev/null +++ b/src/3rdparty/sodium/crypto_pwhash.h @@ -0,0 +1,147 @@ +#ifndef crypto_pwhash_H +#define crypto_pwhash_H + +#include + +#include "crypto_pwhash_argon2i.h" +#include "crypto_pwhash_argon2id.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_pwhash_ALG_ARGON2I13 crypto_pwhash_argon2i_ALG_ARGON2I13 +SODIUM_EXPORT +int crypto_pwhash_alg_argon2i13(void); + +#define crypto_pwhash_ALG_ARGON2ID13 crypto_pwhash_argon2id_ALG_ARGON2ID13 +SODIUM_EXPORT +int crypto_pwhash_alg_argon2id13(void); + +#define crypto_pwhash_ALG_DEFAULT crypto_pwhash_ALG_ARGON2ID13 +SODIUM_EXPORT +int crypto_pwhash_alg_default(void); + +#define crypto_pwhash_BYTES_MIN crypto_pwhash_argon2id_BYTES_MIN +SODIUM_EXPORT +size_t crypto_pwhash_bytes_min(void); + +#define crypto_pwhash_BYTES_MAX crypto_pwhash_argon2id_BYTES_MAX +SODIUM_EXPORT +size_t crypto_pwhash_bytes_max(void); + +#define crypto_pwhash_PASSWD_MIN crypto_pwhash_argon2id_PASSWD_MIN +SODIUM_EXPORT +size_t crypto_pwhash_passwd_min(void); + +#define crypto_pwhash_PASSWD_MAX crypto_pwhash_argon2id_PASSWD_MAX +SODIUM_EXPORT +size_t crypto_pwhash_passwd_max(void); + +#define crypto_pwhash_SALTBYTES crypto_pwhash_argon2id_SALTBYTES +SODIUM_EXPORT +size_t crypto_pwhash_saltbytes(void); + +#define crypto_pwhash_STRBYTES crypto_pwhash_argon2id_STRBYTES +SODIUM_EXPORT +size_t crypto_pwhash_strbytes(void); + +#define crypto_pwhash_STRPREFIX crypto_pwhash_argon2id_STRPREFIX +SODIUM_EXPORT +const char *crypto_pwhash_strprefix(void); + +#define crypto_pwhash_OPSLIMIT_MIN crypto_pwhash_argon2id_OPSLIMIT_MIN +SODIUM_EXPORT +size_t crypto_pwhash_opslimit_min(void); + +#define crypto_pwhash_OPSLIMIT_MAX crypto_pwhash_argon2id_OPSLIMIT_MAX +SODIUM_EXPORT +size_t crypto_pwhash_opslimit_max(void); + +#define crypto_pwhash_MEMLIMIT_MIN crypto_pwhash_argon2id_MEMLIMIT_MIN +SODIUM_EXPORT +size_t crypto_pwhash_memlimit_min(void); + +#define crypto_pwhash_MEMLIMIT_MAX crypto_pwhash_argon2id_MEMLIMIT_MAX +SODIUM_EXPORT +size_t crypto_pwhash_memlimit_max(void); + +#define crypto_pwhash_OPSLIMIT_INTERACTIVE crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE +SODIUM_EXPORT +size_t crypto_pwhash_opslimit_interactive(void); + +#define crypto_pwhash_MEMLIMIT_INTERACTIVE crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE +SODIUM_EXPORT +size_t crypto_pwhash_memlimit_interactive(void); + +#define crypto_pwhash_OPSLIMIT_MODERATE crypto_pwhash_argon2id_OPSLIMIT_MODERATE +SODIUM_EXPORT +size_t crypto_pwhash_opslimit_moderate(void); + +#define crypto_pwhash_MEMLIMIT_MODERATE crypto_pwhash_argon2id_MEMLIMIT_MODERATE +SODIUM_EXPORT +size_t crypto_pwhash_memlimit_moderate(void); + +#define crypto_pwhash_OPSLIMIT_SENSITIVE crypto_pwhash_argon2id_OPSLIMIT_SENSITIVE +SODIUM_EXPORT +size_t crypto_pwhash_opslimit_sensitive(void); + +#define crypto_pwhash_MEMLIMIT_SENSITIVE crypto_pwhash_argon2id_MEMLIMIT_SENSITIVE +SODIUM_EXPORT +size_t crypto_pwhash_memlimit_sensitive(void); + +/* + * With this function, do not forget to store all parameters, including the + * algorithm identifier in order to produce deterministic output. + * The crypto_pwhash_* definitions, including crypto_pwhash_ALG_DEFAULT, + * may change. + */ +SODIUM_EXPORT +int crypto_pwhash(unsigned char * const out, unsigned long long outlen, + const char * const passwd, unsigned long long passwdlen, + const unsigned char * const salt, + unsigned long long opslimit, size_t memlimit, int alg) + __attribute__ ((warn_unused_result)); + +/* + * The output string already includes all the required parameters, including + * the algorithm identifier. The string is all that has to be stored in + * order to verify a password. + */ +SODIUM_EXPORT +int crypto_pwhash_str(char out[crypto_pwhash_STRBYTES], + const char * const passwd, unsigned long long passwdlen, + unsigned long long opslimit, size_t memlimit) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_pwhash_str_alg(char out[crypto_pwhash_STRBYTES], + const char * const passwd, unsigned long long passwdlen, + unsigned long long opslimit, size_t memlimit, int alg) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_pwhash_str_verify(const char str[crypto_pwhash_STRBYTES], + const char * const passwd, + unsigned long long passwdlen) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_pwhash_str_needs_rehash(const char str[crypto_pwhash_STRBYTES], + unsigned long long opslimit, size_t memlimit) + __attribute__ ((warn_unused_result)); + +#define crypto_pwhash_PRIMITIVE "argon2i" +SODIUM_EXPORT +const char *crypto_pwhash_primitive(void) + __attribute__ ((warn_unused_result)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_pwhash_argon2i.h b/src/3rdparty/sodium/crypto_pwhash_argon2i.h new file mode 100644 index 0000000..8e4c1c3 --- /dev/null +++ b/src/3rdparty/sodium/crypto_pwhash_argon2i.h @@ -0,0 +1,122 @@ +#ifndef crypto_pwhash_argon2i_H +#define crypto_pwhash_argon2i_H + +#include +#include +#include + +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_pwhash_argon2i_ALG_ARGON2I13 1 +SODIUM_EXPORT +int crypto_pwhash_argon2i_alg_argon2i13(void); + +#define crypto_pwhash_argon2i_BYTES_MIN 16U +SODIUM_EXPORT +size_t crypto_pwhash_argon2i_bytes_min(void); + +#define crypto_pwhash_argon2i_BYTES_MAX SODIUM_MIN(SODIUM_SIZE_MAX, 4294967295U) +SODIUM_EXPORT +size_t crypto_pwhash_argon2i_bytes_max(void); + +#define crypto_pwhash_argon2i_PASSWD_MIN 0U +SODIUM_EXPORT +size_t crypto_pwhash_argon2i_passwd_min(void); + +#define crypto_pwhash_argon2i_PASSWD_MAX 4294967295U +SODIUM_EXPORT +size_t crypto_pwhash_argon2i_passwd_max(void); + +#define crypto_pwhash_argon2i_SALTBYTES 16U +SODIUM_EXPORT +size_t crypto_pwhash_argon2i_saltbytes(void); + +#define crypto_pwhash_argon2i_STRBYTES 128U +SODIUM_EXPORT +size_t crypto_pwhash_argon2i_strbytes(void); + +#define crypto_pwhash_argon2i_STRPREFIX "$argon2i$" +SODIUM_EXPORT +const char *crypto_pwhash_argon2i_strprefix(void); + +#define crypto_pwhash_argon2i_OPSLIMIT_MIN 3U +SODIUM_EXPORT +size_t crypto_pwhash_argon2i_opslimit_min(void); + +#define crypto_pwhash_argon2i_OPSLIMIT_MAX 4294967295U +SODIUM_EXPORT +size_t crypto_pwhash_argon2i_opslimit_max(void); + +#define crypto_pwhash_argon2i_MEMLIMIT_MIN 8192U +SODIUM_EXPORT +size_t crypto_pwhash_argon2i_memlimit_min(void); + +#define crypto_pwhash_argon2i_MEMLIMIT_MAX \ + ((SIZE_MAX >= 4398046510080U) ? 4398046510080U : (SIZE_MAX >= 2147483648U) ? 2147483648U : 32768U) +SODIUM_EXPORT +size_t crypto_pwhash_argon2i_memlimit_max(void); + +#define crypto_pwhash_argon2i_OPSLIMIT_INTERACTIVE 4U +SODIUM_EXPORT +size_t crypto_pwhash_argon2i_opslimit_interactive(void); + +#define crypto_pwhash_argon2i_MEMLIMIT_INTERACTIVE 33554432U +SODIUM_EXPORT +size_t crypto_pwhash_argon2i_memlimit_interactive(void); + +#define crypto_pwhash_argon2i_OPSLIMIT_MODERATE 6U +SODIUM_EXPORT +size_t crypto_pwhash_argon2i_opslimit_moderate(void); + +#define crypto_pwhash_argon2i_MEMLIMIT_MODERATE 134217728U +SODIUM_EXPORT +size_t crypto_pwhash_argon2i_memlimit_moderate(void); + +#define crypto_pwhash_argon2i_OPSLIMIT_SENSITIVE 8U +SODIUM_EXPORT +size_t crypto_pwhash_argon2i_opslimit_sensitive(void); + +#define crypto_pwhash_argon2i_MEMLIMIT_SENSITIVE 536870912U +SODIUM_EXPORT +size_t crypto_pwhash_argon2i_memlimit_sensitive(void); + +SODIUM_EXPORT +int crypto_pwhash_argon2i(unsigned char * const out, + unsigned long long outlen, + const char * const passwd, + unsigned long long passwdlen, + const unsigned char * const salt, + unsigned long long opslimit, size_t memlimit, + int alg) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_pwhash_argon2i_str(char out[crypto_pwhash_argon2i_STRBYTES], + const char * const passwd, + unsigned long long passwdlen, + unsigned long long opslimit, size_t memlimit) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_pwhash_argon2i_str_verify(const char str[crypto_pwhash_argon2i_STRBYTES], + const char * const passwd, + unsigned long long passwdlen) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_pwhash_argon2i_str_needs_rehash(const char str[crypto_pwhash_argon2i_STRBYTES], + unsigned long long opslimit, size_t memlimit) + __attribute__ ((warn_unused_result)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_pwhash_argon2id.h b/src/3rdparty/sodium/crypto_pwhash_argon2id.h new file mode 100644 index 0000000..51b17aa --- /dev/null +++ b/src/3rdparty/sodium/crypto_pwhash_argon2id.h @@ -0,0 +1,122 @@ +#ifndef crypto_pwhash_argon2id_H +#define crypto_pwhash_argon2id_H + +#include +#include +#include + +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_pwhash_argon2id_ALG_ARGON2ID13 2 +SODIUM_EXPORT +int crypto_pwhash_argon2id_alg_argon2id13(void); + +#define crypto_pwhash_argon2id_BYTES_MIN 16U +SODIUM_EXPORT +size_t crypto_pwhash_argon2id_bytes_min(void); + +#define crypto_pwhash_argon2id_BYTES_MAX SODIUM_MIN(SODIUM_SIZE_MAX, 4294967295U) +SODIUM_EXPORT +size_t crypto_pwhash_argon2id_bytes_max(void); + +#define crypto_pwhash_argon2id_PASSWD_MIN 0U +SODIUM_EXPORT +size_t crypto_pwhash_argon2id_passwd_min(void); + +#define crypto_pwhash_argon2id_PASSWD_MAX 4294967295U +SODIUM_EXPORT +size_t crypto_pwhash_argon2id_passwd_max(void); + +#define crypto_pwhash_argon2id_SALTBYTES 16U +SODIUM_EXPORT +size_t crypto_pwhash_argon2id_saltbytes(void); + +#define crypto_pwhash_argon2id_STRBYTES 128U +SODIUM_EXPORT +size_t crypto_pwhash_argon2id_strbytes(void); + +#define crypto_pwhash_argon2id_STRPREFIX "$argon2id$" +SODIUM_EXPORT +const char *crypto_pwhash_argon2id_strprefix(void); + +#define crypto_pwhash_argon2id_OPSLIMIT_MIN 1U +SODIUM_EXPORT +size_t crypto_pwhash_argon2id_opslimit_min(void); + +#define crypto_pwhash_argon2id_OPSLIMIT_MAX 4294967295U +SODIUM_EXPORT +size_t crypto_pwhash_argon2id_opslimit_max(void); + +#define crypto_pwhash_argon2id_MEMLIMIT_MIN 8192U +SODIUM_EXPORT +size_t crypto_pwhash_argon2id_memlimit_min(void); + +#define crypto_pwhash_argon2id_MEMLIMIT_MAX \ + ((SIZE_MAX >= 4398046510080U) ? 4398046510080U : (SIZE_MAX >= 2147483648U) ? 2147483648U : 32768U) +SODIUM_EXPORT +size_t crypto_pwhash_argon2id_memlimit_max(void); + +#define crypto_pwhash_argon2id_OPSLIMIT_INTERACTIVE 2U +SODIUM_EXPORT +size_t crypto_pwhash_argon2id_opslimit_interactive(void); + +#define crypto_pwhash_argon2id_MEMLIMIT_INTERACTIVE 67108864U +SODIUM_EXPORT +size_t crypto_pwhash_argon2id_memlimit_interactive(void); + +#define crypto_pwhash_argon2id_OPSLIMIT_MODERATE 3U +SODIUM_EXPORT +size_t crypto_pwhash_argon2id_opslimit_moderate(void); + +#define crypto_pwhash_argon2id_MEMLIMIT_MODERATE 268435456U +SODIUM_EXPORT +size_t crypto_pwhash_argon2id_memlimit_moderate(void); + +#define crypto_pwhash_argon2id_OPSLIMIT_SENSITIVE 4U +SODIUM_EXPORT +size_t crypto_pwhash_argon2id_opslimit_sensitive(void); + +#define crypto_pwhash_argon2id_MEMLIMIT_SENSITIVE 1073741824U +SODIUM_EXPORT +size_t crypto_pwhash_argon2id_memlimit_sensitive(void); + +SODIUM_EXPORT +int crypto_pwhash_argon2id(unsigned char * const out, + unsigned long long outlen, + const char * const passwd, + unsigned long long passwdlen, + const unsigned char * const salt, + unsigned long long opslimit, size_t memlimit, + int alg) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_pwhash_argon2id_str(char out[crypto_pwhash_argon2id_STRBYTES], + const char * const passwd, + unsigned long long passwdlen, + unsigned long long opslimit, size_t memlimit) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_pwhash_argon2id_str_verify(const char str[crypto_pwhash_argon2id_STRBYTES], + const char * const passwd, + unsigned long long passwdlen) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_pwhash_argon2id_str_needs_rehash(const char str[crypto_pwhash_argon2id_STRBYTES], + unsigned long long opslimit, size_t memlimit) + __attribute__ ((warn_unused_result)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_pwhash_scryptsalsa208sha256.h b/src/3rdparty/sodium/crypto_pwhash_scryptsalsa208sha256.h new file mode 100644 index 0000000..951b87b --- /dev/null +++ b/src/3rdparty/sodium/crypto_pwhash_scryptsalsa208sha256.h @@ -0,0 +1,120 @@ +#ifndef crypto_pwhash_scryptsalsa208sha256_H +#define crypto_pwhash_scryptsalsa208sha256_H + +#include +#include +#include + +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_pwhash_scryptsalsa208sha256_BYTES_MIN 16U +SODIUM_EXPORT +size_t crypto_pwhash_scryptsalsa208sha256_bytes_min(void); + +#define crypto_pwhash_scryptsalsa208sha256_BYTES_MAX \ + SODIUM_MIN(SODIUM_SIZE_MAX, 0x1fffffffe0ULL) +SODIUM_EXPORT +size_t crypto_pwhash_scryptsalsa208sha256_bytes_max(void); + +#define crypto_pwhash_scryptsalsa208sha256_PASSWD_MIN 0U +SODIUM_EXPORT +size_t crypto_pwhash_scryptsalsa208sha256_passwd_min(void); + +#define crypto_pwhash_scryptsalsa208sha256_PASSWD_MAX SODIUM_SIZE_MAX +SODIUM_EXPORT +size_t crypto_pwhash_scryptsalsa208sha256_passwd_max(void); + +#define crypto_pwhash_scryptsalsa208sha256_SALTBYTES 32U +SODIUM_EXPORT +size_t crypto_pwhash_scryptsalsa208sha256_saltbytes(void); + +#define crypto_pwhash_scryptsalsa208sha256_STRBYTES 102U +SODIUM_EXPORT +size_t crypto_pwhash_scryptsalsa208sha256_strbytes(void); + +#define crypto_pwhash_scryptsalsa208sha256_STRPREFIX "$7$" +SODIUM_EXPORT +const char *crypto_pwhash_scryptsalsa208sha256_strprefix(void); + +#define crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MIN 32768U +SODIUM_EXPORT +size_t crypto_pwhash_scryptsalsa208sha256_opslimit_min(void); + +#define crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_MAX 4294967295U +SODIUM_EXPORT +size_t crypto_pwhash_scryptsalsa208sha256_opslimit_max(void); + +#define crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MIN 16777216U +SODIUM_EXPORT +size_t crypto_pwhash_scryptsalsa208sha256_memlimit_min(void); + +#define crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_MAX \ + SODIUM_MIN(SIZE_MAX, 68719476736ULL) +SODIUM_EXPORT +size_t crypto_pwhash_scryptsalsa208sha256_memlimit_max(void); + +#define crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_INTERACTIVE 524288U +SODIUM_EXPORT +size_t crypto_pwhash_scryptsalsa208sha256_opslimit_interactive(void); + +#define crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE 16777216U +SODIUM_EXPORT +size_t crypto_pwhash_scryptsalsa208sha256_memlimit_interactive(void); + +#define crypto_pwhash_scryptsalsa208sha256_OPSLIMIT_SENSITIVE 33554432U +SODIUM_EXPORT +size_t crypto_pwhash_scryptsalsa208sha256_opslimit_sensitive(void); + +#define crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_SENSITIVE 1073741824U +SODIUM_EXPORT +size_t crypto_pwhash_scryptsalsa208sha256_memlimit_sensitive(void); + +SODIUM_EXPORT +int crypto_pwhash_scryptsalsa208sha256(unsigned char * const out, + unsigned long long outlen, + const char * const passwd, + unsigned long long passwdlen, + const unsigned char * const salt, + unsigned long long opslimit, + size_t memlimit) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_pwhash_scryptsalsa208sha256_str(char out[crypto_pwhash_scryptsalsa208sha256_STRBYTES], + const char * const passwd, + unsigned long long passwdlen, + unsigned long long opslimit, + size_t memlimit) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_pwhash_scryptsalsa208sha256_str_verify(const char str[crypto_pwhash_scryptsalsa208sha256_STRBYTES], + const char * const passwd, + unsigned long long passwdlen) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_pwhash_scryptsalsa208sha256_ll(const uint8_t * passwd, size_t passwdlen, + const uint8_t * salt, size_t saltlen, + uint64_t N, uint32_t r, uint32_t p, + uint8_t * buf, size_t buflen) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_pwhash_scryptsalsa208sha256_str_needs_rehash(const char str[crypto_pwhash_scryptsalsa208sha256_STRBYTES], + unsigned long long opslimit, + size_t memlimit) + __attribute__ ((warn_unused_result)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_scalarmult.h b/src/3rdparty/sodium/crypto_scalarmult.h new file mode 100644 index 0000000..f7fa6f8 --- /dev/null +++ b/src/3rdparty/sodium/crypto_scalarmult.h @@ -0,0 +1,45 @@ +#ifndef crypto_scalarmult_H +#define crypto_scalarmult_H + +#include + +#include "crypto_scalarmult_curve25519.h" +#include "export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define crypto_scalarmult_BYTES crypto_scalarmult_curve25519_BYTES +SODIUM_EXPORT +size_t crypto_scalarmult_bytes(void); + +#define crypto_scalarmult_SCALARBYTES crypto_scalarmult_curve25519_SCALARBYTES +SODIUM_EXPORT +size_t crypto_scalarmult_scalarbytes(void); + +#define crypto_scalarmult_PRIMITIVE "curve25519" +SODIUM_EXPORT +const char *crypto_scalarmult_primitive(void); + +SODIUM_EXPORT +int crypto_scalarmult_base(unsigned char *q, const unsigned char *n); + +/* + * NOTE: Do not use the result of this function directly. + * + * Hash the result with the public keys in order to compute a shared + * secret key: H(q || client_pk || server_pk) + * + * Or unless this is not an option, use the crypto_kx() API instead. + */ +SODIUM_EXPORT +int crypto_scalarmult(unsigned char *q, const unsigned char *n, + const unsigned char *p) + __attribute__ ((warn_unused_result)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_scalarmult_curve25519.h b/src/3rdparty/sodium/crypto_scalarmult_curve25519.h new file mode 100644 index 0000000..ae85ead --- /dev/null +++ b/src/3rdparty/sodium/crypto_scalarmult_curve25519.h @@ -0,0 +1,40 @@ +#ifndef crypto_scalarmult_curve25519_H +#define crypto_scalarmult_curve25519_H + +#include + +#include "export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define crypto_scalarmult_curve25519_BYTES 32U +SODIUM_EXPORT +size_t crypto_scalarmult_curve25519_bytes(void); + +#define crypto_scalarmult_curve25519_SCALARBYTES 32U +SODIUM_EXPORT +size_t crypto_scalarmult_curve25519_scalarbytes(void); + +/* + * NOTE: Do not use the result of this function directly. + * + * Hash the result with the public keys in order to compute a shared + * secret key: H(q || client_pk || server_pk) + * + * Or unless this is not an option, use the crypto_kx() API instead. + */ +SODIUM_EXPORT +int crypto_scalarmult_curve25519(unsigned char *q, const unsigned char *n, + const unsigned char *p) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_scalarmult_curve25519_base(unsigned char *q, const unsigned char *n); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_scalarmult_ed25519.h b/src/3rdparty/sodium/crypto_scalarmult_ed25519.h new file mode 100644 index 0000000..3d51235 --- /dev/null +++ b/src/3rdparty/sodium/crypto_scalarmult_ed25519.h @@ -0,0 +1,41 @@ + +#ifndef crypto_scalarmult_ed25519_H +#define crypto_scalarmult_ed25519_H + +#include + +#include "export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define crypto_scalarmult_ed25519_BYTES 32U +SODIUM_EXPORT +size_t crypto_scalarmult_ed25519_bytes(void); + +#define crypto_scalarmult_ed25519_SCALARBYTES 32U +SODIUM_EXPORT +size_t crypto_scalarmult_ed25519_scalarbytes(void); + +/* + * NOTE: Do not use the result of this function directly. + * + * Hash the result with the public keys in order to compute a shared + * secret key: H(q || client_pk || server_pk) + * + * Or unless this is not an option, use the crypto_kx() API instead. + */ +SODIUM_EXPORT +int crypto_scalarmult_ed25519(unsigned char *q, const unsigned char *n, + const unsigned char *p) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_scalarmult_ed25519_base(unsigned char *q, const unsigned char *n); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_secretbox.h b/src/3rdparty/sodium/crypto_secretbox.h new file mode 100644 index 0000000..55e94a0 --- /dev/null +++ b/src/3rdparty/sodium/crypto_secretbox.h @@ -0,0 +1,91 @@ +#ifndef crypto_secretbox_H +#define crypto_secretbox_H + +#include + +#include "crypto_secretbox_xsalsa20poly1305.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_secretbox_KEYBYTES crypto_secretbox_xsalsa20poly1305_KEYBYTES +SODIUM_EXPORT +size_t crypto_secretbox_keybytes(void); + +#define crypto_secretbox_NONCEBYTES crypto_secretbox_xsalsa20poly1305_NONCEBYTES +SODIUM_EXPORT +size_t crypto_secretbox_noncebytes(void); + +#define crypto_secretbox_MACBYTES crypto_secretbox_xsalsa20poly1305_MACBYTES +SODIUM_EXPORT +size_t crypto_secretbox_macbytes(void); + +#define crypto_secretbox_PRIMITIVE "xsalsa20poly1305" +SODIUM_EXPORT +const char *crypto_secretbox_primitive(void); + +#define crypto_secretbox_MESSAGEBYTES_MAX crypto_secretbox_xsalsa20poly1305_MESSAGEBYTES_MAX +SODIUM_EXPORT +size_t crypto_secretbox_messagebytes_max(void); + +SODIUM_EXPORT +int crypto_secretbox_easy(unsigned char *c, const unsigned char *m, + unsigned long long mlen, const unsigned char *n, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_secretbox_open_easy(unsigned char *m, const unsigned char *c, + unsigned long long clen, const unsigned char *n, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_secretbox_detached(unsigned char *c, unsigned char *mac, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *n, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_secretbox_open_detached(unsigned char *m, + const unsigned char *c, + const unsigned char *mac, + unsigned long long clen, + const unsigned char *n, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +void crypto_secretbox_keygen(unsigned char k[crypto_secretbox_KEYBYTES]); + +/* -- NaCl compatibility interface ; Requires padding -- */ + +#define crypto_secretbox_ZEROBYTES crypto_secretbox_xsalsa20poly1305_ZEROBYTES +SODIUM_EXPORT +size_t crypto_secretbox_zerobytes(void); + +#define crypto_secretbox_BOXZEROBYTES crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES +SODIUM_EXPORT +size_t crypto_secretbox_boxzerobytes(void); + +SODIUM_EXPORT +int crypto_secretbox(unsigned char *c, const unsigned char *m, + unsigned long long mlen, const unsigned char *n, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_secretbox_open(unsigned char *m, const unsigned char *c, + unsigned long long clen, const unsigned char *n, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_secretbox_xchacha20poly1305.h b/src/3rdparty/sodium/crypto_secretbox_xchacha20poly1305.h new file mode 100644 index 0000000..2919da1 --- /dev/null +++ b/src/3rdparty/sodium/crypto_secretbox_xchacha20poly1305.h @@ -0,0 +1,68 @@ +#ifndef crypto_secretbox_xchacha20poly1305_H +#define crypto_secretbox_xchacha20poly1305_H + +#include +#include "crypto_stream_xchacha20.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_secretbox_xchacha20poly1305_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_secretbox_xchacha20poly1305_keybytes(void); + +#define crypto_secretbox_xchacha20poly1305_NONCEBYTES 24U +SODIUM_EXPORT +size_t crypto_secretbox_xchacha20poly1305_noncebytes(void); + +#define crypto_secretbox_xchacha20poly1305_MACBYTES 16U +SODIUM_EXPORT +size_t crypto_secretbox_xchacha20poly1305_macbytes(void); + +#define crypto_secretbox_xchacha20poly1305_MESSAGEBYTES_MAX \ + (crypto_stream_xchacha20_MESSAGEBYTES_MAX - crypto_secretbox_xchacha20poly1305_MACBYTES) +SODIUM_EXPORT +size_t crypto_secretbox_xchacha20poly1305_messagebytes_max(void); + +SODIUM_EXPORT +int crypto_secretbox_xchacha20poly1305_easy(unsigned char *c, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *n, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_secretbox_xchacha20poly1305_open_easy(unsigned char *m, + const unsigned char *c, + unsigned long long clen, + const unsigned char *n, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_secretbox_xchacha20poly1305_detached(unsigned char *c, + unsigned char *mac, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *n, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_secretbox_xchacha20poly1305_open_detached(unsigned char *m, + const unsigned char *c, + const unsigned char *mac, + unsigned long long clen, + const unsigned char *n, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_secretbox_xsalsa20poly1305.h b/src/3rdparty/sodium/crypto_secretbox_xsalsa20poly1305.h new file mode 100644 index 0000000..4b8c7c8 --- /dev/null +++ b/src/3rdparty/sodium/crypto_secretbox_xsalsa20poly1305.h @@ -0,0 +1,67 @@ +#ifndef crypto_secretbox_xsalsa20poly1305_H +#define crypto_secretbox_xsalsa20poly1305_H + +#include +#include "crypto_stream_xsalsa20.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_secretbox_xsalsa20poly1305_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_secretbox_xsalsa20poly1305_keybytes(void); + +#define crypto_secretbox_xsalsa20poly1305_NONCEBYTES 24U +SODIUM_EXPORT +size_t crypto_secretbox_xsalsa20poly1305_noncebytes(void); + +#define crypto_secretbox_xsalsa20poly1305_MACBYTES 16U +SODIUM_EXPORT +size_t crypto_secretbox_xsalsa20poly1305_macbytes(void); + +/* Only for the libsodium API - The NaCl compatibility API would require BOXZEROBYTES extra bytes */ +#define crypto_secretbox_xsalsa20poly1305_MESSAGEBYTES_MAX \ + (crypto_stream_xsalsa20_MESSAGEBYTES_MAX - crypto_secretbox_xsalsa20poly1305_MACBYTES) +SODIUM_EXPORT +size_t crypto_secretbox_xsalsa20poly1305_messagebytes_max(void); + +SODIUM_EXPORT +int crypto_secretbox_xsalsa20poly1305(unsigned char *c, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *n, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_secretbox_xsalsa20poly1305_open(unsigned char *m, + const unsigned char *c, + unsigned long long clen, + const unsigned char *n, + const unsigned char *k) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +void crypto_secretbox_xsalsa20poly1305_keygen(unsigned char k[crypto_secretbox_xsalsa20poly1305_KEYBYTES]); + +/* -- NaCl compatibility interface ; Requires padding -- */ + +#define crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES 16U +SODIUM_EXPORT +size_t crypto_secretbox_xsalsa20poly1305_boxzerobytes(void); + +#define crypto_secretbox_xsalsa20poly1305_ZEROBYTES \ + (crypto_secretbox_xsalsa20poly1305_BOXZEROBYTES + \ + crypto_secretbox_xsalsa20poly1305_MACBYTES) +SODIUM_EXPORT +size_t crypto_secretbox_xsalsa20poly1305_zerobytes(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_secretstream_xchacha20poly1305.h b/src/3rdparty/sodium/crypto_secretstream_xchacha20poly1305.h new file mode 100644 index 0000000..7d3fa2a --- /dev/null +++ b/src/3rdparty/sodium/crypto_secretstream_xchacha20poly1305.h @@ -0,0 +1,102 @@ +#ifndef crypto_secretstream_xchacha20poly1305_H +#define crypto_secretstream_xchacha20poly1305_H + +#include + +#include "crypto_aead_xchacha20poly1305.h" +#include "crypto_stream_chacha20.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_secretstream_xchacha20poly1305_ABYTES \ + (1U + crypto_aead_xchacha20poly1305_ietf_ABYTES) +SODIUM_EXPORT +size_t crypto_secretstream_xchacha20poly1305_abytes(void); + +#define crypto_secretstream_xchacha20poly1305_HEADERBYTES \ + crypto_aead_xchacha20poly1305_ietf_NPUBBYTES +SODIUM_EXPORT +size_t crypto_secretstream_xchacha20poly1305_headerbytes(void); + +#define crypto_secretstream_xchacha20poly1305_KEYBYTES \ + crypto_aead_xchacha20poly1305_ietf_KEYBYTES +SODIUM_EXPORT +size_t crypto_secretstream_xchacha20poly1305_keybytes(void); + +#define crypto_secretstream_xchacha20poly1305_MESSAGEBYTES_MAX \ + SODIUM_MIN(SODIUM_SIZE_MAX, ((1ULL << 32) - 2ULL) * 64ULL) +SODIUM_EXPORT +size_t crypto_secretstream_xchacha20poly1305_messagebytes_max(void); + +#define crypto_secretstream_xchacha20poly1305_TAG_MESSAGE 0x00 +SODIUM_EXPORT +unsigned char crypto_secretstream_xchacha20poly1305_tag_message(void); + +#define crypto_secretstream_xchacha20poly1305_TAG_PUSH 0x01 +SODIUM_EXPORT +unsigned char crypto_secretstream_xchacha20poly1305_tag_push(void); + +#define crypto_secretstream_xchacha20poly1305_TAG_REKEY 0x02 +SODIUM_EXPORT +unsigned char crypto_secretstream_xchacha20poly1305_tag_rekey(void); + +#define crypto_secretstream_xchacha20poly1305_TAG_FINAL \ + (crypto_secretstream_xchacha20poly1305_TAG_PUSH | \ + crypto_secretstream_xchacha20poly1305_TAG_REKEY) +SODIUM_EXPORT +unsigned char crypto_secretstream_xchacha20poly1305_tag_final(void); + +typedef struct crypto_secretstream_xchacha20poly1305_state { + unsigned char k[crypto_stream_chacha20_ietf_KEYBYTES]; + unsigned char nonce[crypto_stream_chacha20_ietf_NONCEBYTES]; + unsigned char _pad[8]; +} crypto_secretstream_xchacha20poly1305_state; + +SODIUM_EXPORT +size_t crypto_secretstream_xchacha20poly1305_statebytes(void); + +SODIUM_EXPORT +void crypto_secretstream_xchacha20poly1305_keygen + (unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES]); + +SODIUM_EXPORT +int crypto_secretstream_xchacha20poly1305_init_push + (crypto_secretstream_xchacha20poly1305_state *state, + unsigned char header[crypto_secretstream_xchacha20poly1305_HEADERBYTES], + const unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES]); + +SODIUM_EXPORT +int crypto_secretstream_xchacha20poly1305_push + (crypto_secretstream_xchacha20poly1305_state *state, + unsigned char *c, unsigned long long *clen_p, + const unsigned char *m, unsigned long long mlen, + const unsigned char *ad, unsigned long long adlen, unsigned char tag); + +SODIUM_EXPORT +int crypto_secretstream_xchacha20poly1305_init_pull + (crypto_secretstream_xchacha20poly1305_state *state, + const unsigned char header[crypto_secretstream_xchacha20poly1305_HEADERBYTES], + const unsigned char k[crypto_secretstream_xchacha20poly1305_KEYBYTES]); + +SODIUM_EXPORT +int crypto_secretstream_xchacha20poly1305_pull + (crypto_secretstream_xchacha20poly1305_state *state, + unsigned char *m, unsigned long long *mlen_p, unsigned char *tag_p, + const unsigned char *c, unsigned long long clen, + const unsigned char *ad, unsigned long long adlen); + +SODIUM_EXPORT +void crypto_secretstream_xchacha20poly1305_rekey + (crypto_secretstream_xchacha20poly1305_state *state); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_shorthash.h b/src/3rdparty/sodium/crypto_shorthash.h new file mode 100644 index 0000000..a498808 --- /dev/null +++ b/src/3rdparty/sodium/crypto_shorthash.h @@ -0,0 +1,39 @@ +#ifndef crypto_shorthash_H +#define crypto_shorthash_H + +#include + +#include "crypto_shorthash_siphash24.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_shorthash_BYTES crypto_shorthash_siphash24_BYTES +SODIUM_EXPORT +size_t crypto_shorthash_bytes(void); + +#define crypto_shorthash_KEYBYTES crypto_shorthash_siphash24_KEYBYTES +SODIUM_EXPORT +size_t crypto_shorthash_keybytes(void); + +#define crypto_shorthash_PRIMITIVE "siphash24" +SODIUM_EXPORT +const char *crypto_shorthash_primitive(void); + +SODIUM_EXPORT +int crypto_shorthash(unsigned char *out, const unsigned char *in, + unsigned long long inlen, const unsigned char *k); + +SODIUM_EXPORT +void crypto_shorthash_keygen(unsigned char k[crypto_shorthash_KEYBYTES]); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_shorthash_siphash24.h b/src/3rdparty/sodium/crypto_shorthash_siphash24.h new file mode 100644 index 0000000..745ed48 --- /dev/null +++ b/src/3rdparty/sodium/crypto_shorthash_siphash24.h @@ -0,0 +1,48 @@ +#ifndef crypto_shorthash_siphash24_H +#define crypto_shorthash_siphash24_H + +#include +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +/* -- 64-bit output -- */ + +#define crypto_shorthash_siphash24_BYTES 8U +SODIUM_EXPORT +size_t crypto_shorthash_siphash24_bytes(void); + +#define crypto_shorthash_siphash24_KEYBYTES 16U +SODIUM_EXPORT +size_t crypto_shorthash_siphash24_keybytes(void); + +SODIUM_EXPORT +int crypto_shorthash_siphash24(unsigned char *out, const unsigned char *in, + unsigned long long inlen, const unsigned char *k); + +#ifndef SODIUM_LIBRARY_MINIMAL +/* -- 128-bit output -- */ + +#define crypto_shorthash_siphashx24_BYTES 16U +SODIUM_EXPORT +size_t crypto_shorthash_siphashx24_bytes(void); + +#define crypto_shorthash_siphashx24_KEYBYTES 16U +SODIUM_EXPORT +size_t crypto_shorthash_siphashx24_keybytes(void); + +SODIUM_EXPORT +int crypto_shorthash_siphashx24(unsigned char *out, const unsigned char *in, + unsigned long long inlen, const unsigned char *k); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_sign.h b/src/3rdparty/sodium/crypto_sign.h new file mode 100644 index 0000000..85aff0c --- /dev/null +++ b/src/3rdparty/sodium/crypto_sign.h @@ -0,0 +1,103 @@ +#ifndef crypto_sign_H +#define crypto_sign_H + +/* + * THREAD SAFETY: crypto_sign_keypair() is thread-safe, + * provided that sodium_init() was called before. + * + * Other functions, including crypto_sign_seed_keypair() are always thread-safe. + */ + +#include + +#include "crypto_sign_ed25519.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +typedef crypto_sign_ed25519ph_state crypto_sign_state; + +SODIUM_EXPORT +size_t crypto_sign_statebytes(void); + +#define crypto_sign_BYTES crypto_sign_ed25519_BYTES +SODIUM_EXPORT +size_t crypto_sign_bytes(void); + +#define crypto_sign_SEEDBYTES crypto_sign_ed25519_SEEDBYTES +SODIUM_EXPORT +size_t crypto_sign_seedbytes(void); + +#define crypto_sign_PUBLICKEYBYTES crypto_sign_ed25519_PUBLICKEYBYTES +SODIUM_EXPORT +size_t crypto_sign_publickeybytes(void); + +#define crypto_sign_SECRETKEYBYTES crypto_sign_ed25519_SECRETKEYBYTES +SODIUM_EXPORT +size_t crypto_sign_secretkeybytes(void); + +#define crypto_sign_MESSAGEBYTES_MAX crypto_sign_ed25519_MESSAGEBYTES_MAX +SODIUM_EXPORT +size_t crypto_sign_messagebytes_max(void); + +#define crypto_sign_PRIMITIVE "ed25519" +SODIUM_EXPORT +const char *crypto_sign_primitive(void); + +SODIUM_EXPORT +int crypto_sign_seed_keypair(unsigned char *pk, unsigned char *sk, + const unsigned char *seed); + +SODIUM_EXPORT +int crypto_sign_keypair(unsigned char *pk, unsigned char *sk); + +SODIUM_EXPORT +int crypto_sign(unsigned char *sm, unsigned long long *smlen_p, + const unsigned char *m, unsigned long long mlen, + const unsigned char *sk); + +SODIUM_EXPORT +int crypto_sign_open(unsigned char *m, unsigned long long *mlen_p, + const unsigned char *sm, unsigned long long smlen, + const unsigned char *pk) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_sign_detached(unsigned char *sig, unsigned long long *siglen_p, + const unsigned char *m, unsigned long long mlen, + const unsigned char *sk); + +SODIUM_EXPORT +int crypto_sign_verify_detached(const unsigned char *sig, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *pk) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_sign_init(crypto_sign_state *state); + +SODIUM_EXPORT +int crypto_sign_update(crypto_sign_state *state, + const unsigned char *m, unsigned long long mlen); + +SODIUM_EXPORT +int crypto_sign_final_create(crypto_sign_state *state, unsigned char *sig, + unsigned long long *siglen_p, + const unsigned char *sk); + +SODIUM_EXPORT +int crypto_sign_final_verify(crypto_sign_state *state, unsigned char *sig, + const unsigned char *pk) + __attribute__ ((warn_unused_result)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_sign_ed25519.h b/src/3rdparty/sodium/crypto_sign_ed25519.h new file mode 100644 index 0000000..38d2b9d --- /dev/null +++ b/src/3rdparty/sodium/crypto_sign_ed25519.h @@ -0,0 +1,114 @@ +#ifndef crypto_sign_ed25519_H +#define crypto_sign_ed25519_H + +#include +#include "crypto_hash_sha512.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +typedef struct crypto_sign_ed25519ph_state { + crypto_hash_sha512_state hs; +} crypto_sign_ed25519ph_state; + +SODIUM_EXPORT +size_t crypto_sign_ed25519ph_statebytes(void); + +#define crypto_sign_ed25519_BYTES 64U +SODIUM_EXPORT +size_t crypto_sign_ed25519_bytes(void); + +#define crypto_sign_ed25519_SEEDBYTES 32U +SODIUM_EXPORT +size_t crypto_sign_ed25519_seedbytes(void); + +#define crypto_sign_ed25519_PUBLICKEYBYTES 32U +SODIUM_EXPORT +size_t crypto_sign_ed25519_publickeybytes(void); + +#define crypto_sign_ed25519_SECRETKEYBYTES (32U + 32U) +SODIUM_EXPORT +size_t crypto_sign_ed25519_secretkeybytes(void); + +#define crypto_sign_ed25519_MESSAGEBYTES_MAX (SODIUM_SIZE_MAX - crypto_sign_ed25519_BYTES) +SODIUM_EXPORT +size_t crypto_sign_ed25519_messagebytes_max(void); + +SODIUM_EXPORT +int crypto_sign_ed25519(unsigned char *sm, unsigned long long *smlen_p, + const unsigned char *m, unsigned long long mlen, + const unsigned char *sk); + +SODIUM_EXPORT +int crypto_sign_ed25519_open(unsigned char *m, unsigned long long *mlen_p, + const unsigned char *sm, unsigned long long smlen, + const unsigned char *pk) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_sign_ed25519_detached(unsigned char *sig, + unsigned long long *siglen_p, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *sk); + +SODIUM_EXPORT +int crypto_sign_ed25519_verify_detached(const unsigned char *sig, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *pk) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_sign_ed25519_keypair(unsigned char *pk, unsigned char *sk); + +SODIUM_EXPORT +int crypto_sign_ed25519_seed_keypair(unsigned char *pk, unsigned char *sk, + const unsigned char *seed); + +SODIUM_EXPORT +int crypto_sign_ed25519_pk_to_curve25519(unsigned char *curve25519_pk, + const unsigned char *ed25519_pk) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int crypto_sign_ed25519_sk_to_curve25519(unsigned char *curve25519_sk, + const unsigned char *ed25519_sk); + +SODIUM_EXPORT +int crypto_sign_ed25519_sk_to_seed(unsigned char *seed, + const unsigned char *sk); + +SODIUM_EXPORT +int crypto_sign_ed25519_sk_to_pk(unsigned char *pk, const unsigned char *sk); + +SODIUM_EXPORT +int crypto_sign_ed25519ph_init(crypto_sign_ed25519ph_state *state); + +SODIUM_EXPORT +int crypto_sign_ed25519ph_update(crypto_sign_ed25519ph_state *state, + const unsigned char *m, + unsigned long long mlen); + +SODIUM_EXPORT +int crypto_sign_ed25519ph_final_create(crypto_sign_ed25519ph_state *state, + unsigned char *sig, + unsigned long long *siglen_p, + const unsigned char *sk); + +SODIUM_EXPORT +int crypto_sign_ed25519ph_final_verify(crypto_sign_ed25519ph_state *state, + unsigned char *sig, + const unsigned char *pk) + __attribute__ ((warn_unused_result)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_sign_edwards25519sha512batch.h b/src/3rdparty/sodium/crypto_sign_edwards25519sha512batch.h new file mode 100644 index 0000000..4bb9192 --- /dev/null +++ b/src/3rdparty/sodium/crypto_sign_edwards25519sha512batch.h @@ -0,0 +1,55 @@ +#ifndef crypto_sign_edwards25519sha512batch_H +#define crypto_sign_edwards25519sha512batch_H + +/* + * WARNING: This construction was a prototype, which should not be used + * any more in new projects. + * + * crypto_sign_edwards25519sha512batch is provided for applications + * initially built with NaCl, but as recommended by the author of this + * construction, new applications should use ed25519 instead. + * + * In Sodium, you should use the high-level crypto_sign_*() functions instead. + */ + +#include +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_sign_edwards25519sha512batch_BYTES 64U +#define crypto_sign_edwards25519sha512batch_PUBLICKEYBYTES 32U +#define crypto_sign_edwards25519sha512batch_SECRETKEYBYTES (32U + 32U) +#define crypto_sign_edwards25519sha512batch_MESSAGEBYTES_MAX (SODIUM_SIZE_MAX - crypto_sign_edwards25519sha512batch_BYTES) + +SODIUM_EXPORT +int crypto_sign_edwards25519sha512batch(unsigned char *sm, + unsigned long long *smlen_p, + const unsigned char *m, + unsigned long long mlen, + const unsigned char *sk) + __attribute__ ((deprecated)); + +SODIUM_EXPORT +int crypto_sign_edwards25519sha512batch_open(unsigned char *m, + unsigned long long *mlen_p, + const unsigned char *sm, + unsigned long long smlen, + const unsigned char *pk) + __attribute__ ((deprecated)); + +SODIUM_EXPORT +int crypto_sign_edwards25519sha512batch_keypair(unsigned char *pk, + unsigned char *sk) + __attribute__ ((deprecated)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_stream.h b/src/3rdparty/sodium/crypto_stream.h new file mode 100644 index 0000000..d288f0b --- /dev/null +++ b/src/3rdparty/sodium/crypto_stream.h @@ -0,0 +1,56 @@ +#ifndef crypto_stream_H +#define crypto_stream_H + +/* + * WARNING: This is just a stream cipher. It is NOT authenticated encryption. + * While it provides some protection against eavesdropping, it does NOT + * provide any security against active attacks. + * Unless you know what you're doing, what you are looking for is probably + * the crypto_box functions. + */ + +#include + +#include "crypto_stream_xsalsa20.h" +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_stream_KEYBYTES crypto_stream_xsalsa20_KEYBYTES +SODIUM_EXPORT +size_t crypto_stream_keybytes(void); + +#define crypto_stream_NONCEBYTES crypto_stream_xsalsa20_NONCEBYTES +SODIUM_EXPORT +size_t crypto_stream_noncebytes(void); + +#define crypto_stream_MESSAGEBYTES_MAX crypto_stream_xsalsa20_MESSAGEBYTES_MAX +SODIUM_EXPORT +size_t crypto_stream_messagebytes_max(void); + +#define crypto_stream_PRIMITIVE "xsalsa20" +SODIUM_EXPORT +const char *crypto_stream_primitive(void); + +SODIUM_EXPORT +int crypto_stream(unsigned char *c, unsigned long long clen, + const unsigned char *n, const unsigned char *k); + +SODIUM_EXPORT +int crypto_stream_xor(unsigned char *c, const unsigned char *m, + unsigned long long mlen, const unsigned char *n, + const unsigned char *k); + +SODIUM_EXPORT +void crypto_stream_keygen(unsigned char k[crypto_stream_KEYBYTES]); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_stream_chacha20.h b/src/3rdparty/sodium/crypto_stream_chacha20.h new file mode 100644 index 0000000..d3e2b23 --- /dev/null +++ b/src/3rdparty/sodium/crypto_stream_chacha20.h @@ -0,0 +1,98 @@ +#ifndef crypto_stream_chacha20_H +#define crypto_stream_chacha20_H + +/* + * WARNING: This is just a stream cipher. It is NOT authenticated encryption. + * While it provides some protection against eavesdropping, it does NOT + * provide any security against active attacks. + * Unless you know what you're doing, what you are looking for is probably + * the crypto_box functions. + */ + +#include +#include +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_stream_chacha20_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_stream_chacha20_keybytes(void); + +#define crypto_stream_chacha20_NONCEBYTES 8U +SODIUM_EXPORT +size_t crypto_stream_chacha20_noncebytes(void); + +#define crypto_stream_chacha20_MESSAGEBYTES_MAX SODIUM_SIZE_MAX +SODIUM_EXPORT +size_t crypto_stream_chacha20_messagebytes_max(void); + +/* ChaCha20 with a 64-bit nonce and a 64-bit counter, as originally designed */ + +SODIUM_EXPORT +int crypto_stream_chacha20(unsigned char *c, unsigned long long clen, + const unsigned char *n, const unsigned char *k); + +SODIUM_EXPORT +int crypto_stream_chacha20_xor(unsigned char *c, const unsigned char *m, + unsigned long long mlen, const unsigned char *n, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_stream_chacha20_xor_ic(unsigned char *c, const unsigned char *m, + unsigned long long mlen, + const unsigned char *n, uint64_t ic, + const unsigned char *k); + +SODIUM_EXPORT +void crypto_stream_chacha20_keygen(unsigned char k[crypto_stream_chacha20_KEYBYTES]); + +/* ChaCha20 with a 96-bit nonce and a 32-bit counter (IETF) */ + +#define crypto_stream_chacha20_ietf_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_stream_chacha20_ietf_keybytes(void); + +#define crypto_stream_chacha20_ietf_NONCEBYTES 12U +SODIUM_EXPORT +size_t crypto_stream_chacha20_ietf_noncebytes(void); + +#define crypto_stream_chacha20_ietf_MESSAGEBYTES_MAX \ + SODIUM_MIN(SODIUM_SIZE_MAX, 64ULL * (1ULL << 32)) +SODIUM_EXPORT +size_t crypto_stream_chacha20_ietf_messagebytes_max(void); + +SODIUM_EXPORT +int crypto_stream_chacha20_ietf(unsigned char *c, unsigned long long clen, + const unsigned char *n, const unsigned char *k); + +SODIUM_EXPORT +int crypto_stream_chacha20_ietf_xor(unsigned char *c, const unsigned char *m, + unsigned long long mlen, const unsigned char *n, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_stream_chacha20_ietf_xor_ic(unsigned char *c, const unsigned char *m, + unsigned long long mlen, + const unsigned char *n, uint32_t ic, + const unsigned char *k); + +SODIUM_EXPORT +void crypto_stream_chacha20_ietf_keygen(unsigned char k[crypto_stream_chacha20_ietf_KEYBYTES]); + +/* Aliases */ + +#define crypto_stream_chacha20_IETF_KEYBYTES crypto_stream_chacha20_ietf_KEYBYTES +#define crypto_stream_chacha20_IETF_NONCEBYTES crypto_stream_chacha20_ietf_NONCEBYTES +#define crypto_stream_chacha20_IETF_MESSAGEBYTES_MAX crypto_stream_chacha20_ietf_MESSAGEBYTES_MAX + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_stream_salsa20.h b/src/3rdparty/sodium/crypto_stream_salsa20.h new file mode 100644 index 0000000..0c7688c --- /dev/null +++ b/src/3rdparty/sodium/crypto_stream_salsa20.h @@ -0,0 +1,57 @@ +#ifndef crypto_stream_salsa20_H +#define crypto_stream_salsa20_H + +/* + * WARNING: This is just a stream cipher. It is NOT authenticated encryption. + * While it provides some protection against eavesdropping, it does NOT + * provide any security against active attacks. + * Unless you know what you're doing, what you are looking for is probably + * the crypto_box functions. + */ + +#include +#include +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_stream_salsa20_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_stream_salsa20_keybytes(void); + +#define crypto_stream_salsa20_NONCEBYTES 8U +SODIUM_EXPORT +size_t crypto_stream_salsa20_noncebytes(void); + +#define crypto_stream_salsa20_MESSAGEBYTES_MAX SODIUM_SIZE_MAX +SODIUM_EXPORT +size_t crypto_stream_salsa20_messagebytes_max(void); + +SODIUM_EXPORT +int crypto_stream_salsa20(unsigned char *c, unsigned long long clen, + const unsigned char *n, const unsigned char *k); + +SODIUM_EXPORT +int crypto_stream_salsa20_xor(unsigned char *c, const unsigned char *m, + unsigned long long mlen, const unsigned char *n, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_stream_salsa20_xor_ic(unsigned char *c, const unsigned char *m, + unsigned long long mlen, + const unsigned char *n, uint64_t ic, + const unsigned char *k); + +SODIUM_EXPORT +void crypto_stream_salsa20_keygen(unsigned char k[crypto_stream_salsa20_KEYBYTES]); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_stream_salsa2012.h b/src/3rdparty/sodium/crypto_stream_salsa2012.h new file mode 100644 index 0000000..c93d1c8 --- /dev/null +++ b/src/3rdparty/sodium/crypto_stream_salsa2012.h @@ -0,0 +1,50 @@ +#ifndef crypto_stream_salsa2012_H +#define crypto_stream_salsa2012_H + +/* + * WARNING: This is just a stream cipher. It is NOT authenticated encryption. + * While it provides some protection against eavesdropping, it does NOT + * provide any security against active attacks. + * Unless you know what you're doing, what you are looking for is probably + * the crypto_box functions. + */ + +#include +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_stream_salsa2012_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_stream_salsa2012_keybytes(void); + +#define crypto_stream_salsa2012_NONCEBYTES 8U +SODIUM_EXPORT +size_t crypto_stream_salsa2012_noncebytes(void); + +#define crypto_stream_salsa2012_MESSAGEBYTES_MAX SODIUM_SIZE_MAX +SODIUM_EXPORT +size_t crypto_stream_salsa2012_messagebytes_max(void); + +SODIUM_EXPORT +int crypto_stream_salsa2012(unsigned char *c, unsigned long long clen, + const unsigned char *n, const unsigned char *k); + +SODIUM_EXPORT +int crypto_stream_salsa2012_xor(unsigned char *c, const unsigned char *m, + unsigned long long mlen, const unsigned char *n, + const unsigned char *k); + +SODIUM_EXPORT +void crypto_stream_salsa2012_keygen(unsigned char k[crypto_stream_salsa2012_KEYBYTES]); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_stream_salsa208.h b/src/3rdparty/sodium/crypto_stream_salsa208.h new file mode 100644 index 0000000..653f650 --- /dev/null +++ b/src/3rdparty/sodium/crypto_stream_salsa208.h @@ -0,0 +1,56 @@ +#ifndef crypto_stream_salsa208_H +#define crypto_stream_salsa208_H + +/* + * WARNING: This is just a stream cipher. It is NOT authenticated encryption. + * While it provides some protection against eavesdropping, it does NOT + * provide any security against active attacks. + * Unless you know what you're doing, what you are looking for is probably + * the crypto_box functions. + */ + +#include +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_stream_salsa208_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_stream_salsa208_keybytes(void) + __attribute__ ((deprecated)); + +#define crypto_stream_salsa208_NONCEBYTES 8U +SODIUM_EXPORT +size_t crypto_stream_salsa208_noncebytes(void) + __attribute__ ((deprecated)); + +#define crypto_stream_salsa208_MESSAGEBYTES_MAX SODIUM_SIZE_MAX + SODIUM_EXPORT +size_t crypto_stream_salsa208_messagebytes_max(void) + __attribute__ ((deprecated)); + +SODIUM_EXPORT +int crypto_stream_salsa208(unsigned char *c, unsigned long long clen, + const unsigned char *n, const unsigned char *k) + __attribute__ ((deprecated)); + +SODIUM_EXPORT +int crypto_stream_salsa208_xor(unsigned char *c, const unsigned char *m, + unsigned long long mlen, const unsigned char *n, + const unsigned char *k) + __attribute__ ((deprecated)); + +SODIUM_EXPORT +void crypto_stream_salsa208_keygen(unsigned char k[crypto_stream_salsa208_KEYBYTES]) + __attribute__ ((deprecated)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_stream_xchacha20.h b/src/3rdparty/sodium/crypto_stream_xchacha20.h new file mode 100644 index 0000000..cf0407f --- /dev/null +++ b/src/3rdparty/sodium/crypto_stream_xchacha20.h @@ -0,0 +1,57 @@ +#ifndef crypto_stream_xchacha20_H +#define crypto_stream_xchacha20_H + +/* + * WARNING: This is just a stream cipher. It is NOT authenticated encryption. + * While it provides some protection against eavesdropping, it does NOT + * provide any security against active attacks. + * Unless you know what you're doing, what you are looking for is probably + * the crypto_box functions. + */ + +#include +#include +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_stream_xchacha20_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_stream_xchacha20_keybytes(void); + +#define crypto_stream_xchacha20_NONCEBYTES 24U +SODIUM_EXPORT +size_t crypto_stream_xchacha20_noncebytes(void); + +#define crypto_stream_xchacha20_MESSAGEBYTES_MAX SODIUM_SIZE_MAX +SODIUM_EXPORT +size_t crypto_stream_xchacha20_messagebytes_max(void); + +SODIUM_EXPORT +int crypto_stream_xchacha20(unsigned char *c, unsigned long long clen, + const unsigned char *n, const unsigned char *k); + +SODIUM_EXPORT +int crypto_stream_xchacha20_xor(unsigned char *c, const unsigned char *m, + unsigned long long mlen, const unsigned char *n, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_stream_xchacha20_xor_ic(unsigned char *c, const unsigned char *m, + unsigned long long mlen, + const unsigned char *n, uint64_t ic, + const unsigned char *k); + +SODIUM_EXPORT +void crypto_stream_xchacha20_keygen(unsigned char k[crypto_stream_xchacha20_KEYBYTES]); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_stream_xsalsa20.h b/src/3rdparty/sodium/crypto_stream_xsalsa20.h new file mode 100644 index 0000000..cb4c44a --- /dev/null +++ b/src/3rdparty/sodium/crypto_stream_xsalsa20.h @@ -0,0 +1,57 @@ +#ifndef crypto_stream_xsalsa20_H +#define crypto_stream_xsalsa20_H + +/* + * WARNING: This is just a stream cipher. It is NOT authenticated encryption. + * While it provides some protection against eavesdropping, it does NOT + * provide any security against active attacks. + * Unless you know what you're doing, what you are looking for is probably + * the crypto_box functions. + */ + +#include +#include +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +#define crypto_stream_xsalsa20_KEYBYTES 32U +SODIUM_EXPORT +size_t crypto_stream_xsalsa20_keybytes(void); + +#define crypto_stream_xsalsa20_NONCEBYTES 24U +SODIUM_EXPORT +size_t crypto_stream_xsalsa20_noncebytes(void); + +#define crypto_stream_xsalsa20_MESSAGEBYTES_MAX SODIUM_SIZE_MAX +SODIUM_EXPORT +size_t crypto_stream_xsalsa20_messagebytes_max(void); + +SODIUM_EXPORT +int crypto_stream_xsalsa20(unsigned char *c, unsigned long long clen, + const unsigned char *n, const unsigned char *k); + +SODIUM_EXPORT +int crypto_stream_xsalsa20_xor(unsigned char *c, const unsigned char *m, + unsigned long long mlen, const unsigned char *n, + const unsigned char *k); + +SODIUM_EXPORT +int crypto_stream_xsalsa20_xor_ic(unsigned char *c, const unsigned char *m, + unsigned long long mlen, + const unsigned char *n, uint64_t ic, + const unsigned char *k); + +SODIUM_EXPORT +void crypto_stream_xsalsa20_keygen(unsigned char k[crypto_stream_xsalsa20_KEYBYTES]); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_verify_16.h b/src/3rdparty/sodium/crypto_verify_16.h new file mode 100644 index 0000000..5e9eeab --- /dev/null +++ b/src/3rdparty/sodium/crypto_verify_16.h @@ -0,0 +1,23 @@ +#ifndef crypto_verify_16_H +#define crypto_verify_16_H + +#include +#include "export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define crypto_verify_16_BYTES 16U +SODIUM_EXPORT +size_t crypto_verify_16_bytes(void); + +SODIUM_EXPORT +int crypto_verify_16(const unsigned char *x, const unsigned char *y) + __attribute__ ((warn_unused_result)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_verify_32.h b/src/3rdparty/sodium/crypto_verify_32.h new file mode 100644 index 0000000..281b5a1 --- /dev/null +++ b/src/3rdparty/sodium/crypto_verify_32.h @@ -0,0 +1,23 @@ +#ifndef crypto_verify_32_H +#define crypto_verify_32_H + +#include +#include "export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define crypto_verify_32_BYTES 32U +SODIUM_EXPORT +size_t crypto_verify_32_bytes(void); + +SODIUM_EXPORT +int crypto_verify_32(const unsigned char *x, const unsigned char *y) + __attribute__ ((warn_unused_result)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/crypto_verify_64.h b/src/3rdparty/sodium/crypto_verify_64.h new file mode 100644 index 0000000..0dc7c30 --- /dev/null +++ b/src/3rdparty/sodium/crypto_verify_64.h @@ -0,0 +1,23 @@ +#ifndef crypto_verify_64_H +#define crypto_verify_64_H + +#include +#include "export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define crypto_verify_64_BYTES 64U +SODIUM_EXPORT +size_t crypto_verify_64_bytes(void); + +SODIUM_EXPORT +int crypto_verify_64(const unsigned char *x, const unsigned char *y) + __attribute__ ((warn_unused_result)); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/export.h b/src/3rdparty/sodium/export.h new file mode 100644 index 0000000..0f624ae --- /dev/null +++ b/src/3rdparty/sodium/export.h @@ -0,0 +1,53 @@ + +#ifndef sodium_export_H +#define sodium_export_H + +#ifndef __GNUC__ +# ifdef __attribute__ +# undef __attribute__ +# endif +# define __attribute__(a) +#endif + +#ifdef SODIUM_STATIC +# define SODIUM_EXPORT +# define SODIUM_EXPORT_WEAK +#else +# if defined(_MSC_VER) +# ifdef SODIUM_DLL_EXPORT +# define SODIUM_EXPORT __declspec(dllexport) +# else +# define SODIUM_EXPORT __declspec(dllimport) +# endif +# else +# if defined(__SUNPRO_C) +# ifndef __GNU_C__ +# define SODIUM_EXPORT __attribute__ (visibility(__global)) +# else +# define SODIUM_EXPORT __attribute__ __global +# endif +# elif defined(_MSG_VER) +# define SODIUM_EXPORT extern __declspec(dllexport) +# else +# define SODIUM_EXPORT __attribute__ ((visibility ("default"))) +# endif +# endif +# if defined(__ELF__) && !defined(SODIUM_DISABLE_WEAK_FUNCTIONS) +# define SODIUM_EXPORT_WEAK SODIUM_EXPORT __attribute__((weak)) +# else +# define SODIUM_EXPORT_WEAK SODIUM_EXPORT +# endif +#endif + +#ifndef CRYPTO_ALIGN +# if defined(__INTEL_COMPILER) || defined(_MSC_VER) +# define CRYPTO_ALIGN(x) __declspec(align(x)) +# else +# define CRYPTO_ALIGN(x) __attribute__ ((aligned(x))) +# endif +#endif + +#define SODIUM_MIN(A, B) ((A) < (B) ? (A) : (B)) +#define SODIUM_SIZE_MAX SODIUM_MIN(UINT64_MAX, SIZE_MAX) + +#endif diff --git a/src/3rdparty/sodium/private/common.h b/src/3rdparty/sodium/private/common.h new file mode 100644 index 0000000..954d02c --- /dev/null +++ b/src/3rdparty/sodium/private/common.h @@ -0,0 +1,246 @@ +#ifndef common_H +#define common_H 1 + +#include +#include +#include + +#define COMPILER_ASSERT(X) (void) sizeof(char[(X) ? 1 : -1]) + +#ifdef HAVE_TI_MODE +# if defined(__SIZEOF_INT128__) +typedef unsigned __int128 uint128_t; +# else +typedef unsigned uint128_t __attribute__((mode(TI))); +# endif +#endif + +#define ROTL32(X, B) rotl32((X), (B)) +static inline uint32_t +rotl32(const uint32_t x, const int b) +{ + return (x << b) | (x >> (32 - b)); +} + +#define ROTL64(X, B) rotl64((X), (B)) +static inline uint64_t +rotl64(const uint64_t x, const int b) +{ + return (x << b) | (x >> (64 - b)); +} + +#define ROTR32(X, B) rotr32((X), (B)) +static inline uint32_t +rotr32(const uint32_t x, const int b) +{ + return (x >> b) | (x << (32 - b)); +} + +#define ROTR64(X, B) rotr64((X), (B)) +static inline uint64_t +rotr64(const uint64_t x, const int b) +{ + return (x >> b) | (x << (64 - b)); +} + +#define LOAD64_LE(SRC) load64_le(SRC) +static inline uint64_t +load64_le(const uint8_t src[8]) +{ +#ifdef NATIVE_LITTLE_ENDIAN + uint64_t w; + memcpy(&w, src, sizeof w); + return w; +#else + uint64_t w = (uint64_t) src[0]; + w |= (uint64_t) src[1] << 8; + w |= (uint64_t) src[2] << 16; + w |= (uint64_t) src[3] << 24; + w |= (uint64_t) src[4] << 32; + w |= (uint64_t) src[5] << 40; + w |= (uint64_t) src[6] << 48; + w |= (uint64_t) src[7] << 56; + return w; +#endif +} + +#define STORE64_LE(DST, W) store64_le((DST), (W)) +static inline void +store64_le(uint8_t dst[8], uint64_t w) +{ +#ifdef NATIVE_LITTLE_ENDIAN + memcpy(dst, &w, sizeof w); +#else + dst[0] = (uint8_t) w; w >>= 8; + dst[1] = (uint8_t) w; w >>= 8; + dst[2] = (uint8_t) w; w >>= 8; + dst[3] = (uint8_t) w; w >>= 8; + dst[4] = (uint8_t) w; w >>= 8; + dst[5] = (uint8_t) w; w >>= 8; + dst[6] = (uint8_t) w; w >>= 8; + dst[7] = (uint8_t) w; +#endif +} + +#define LOAD32_LE(SRC) load32_le(SRC) +static inline uint32_t +load32_le(const uint8_t src[4]) +{ +#ifdef NATIVE_LITTLE_ENDIAN + uint32_t w; + memcpy(&w, src, sizeof w); + return w; +#else + uint32_t w = (uint32_t) src[0]; + w |= (uint32_t) src[1] << 8; + w |= (uint32_t) src[2] << 16; + w |= (uint32_t) src[3] << 24; + return w; +#endif +} + +#define STORE32_LE(DST, W) store32_le((DST), (W)) +static inline void +store32_le(uint8_t dst[4], uint32_t w) +{ +#ifdef NATIVE_LITTLE_ENDIAN + memcpy(dst, &w, sizeof w); +#else + dst[0] = (uint8_t) w; w >>= 8; + dst[1] = (uint8_t) w; w >>= 8; + dst[2] = (uint8_t) w; w >>= 8; + dst[3] = (uint8_t) w; +#endif +} + +/* ----- */ + +#define LOAD64_BE(SRC) load64_be(SRC) +static inline uint64_t +load64_be(const uint8_t src[8]) +{ +#ifdef NATIVE_BIG_ENDIAN + uint64_t w; + memcpy(&w, src, sizeof w); + return w; +#else + uint64_t w = (uint64_t) src[7]; + w |= (uint64_t) src[6] << 8; + w |= (uint64_t) src[5] << 16; + w |= (uint64_t) src[4] << 24; + w |= (uint64_t) src[3] << 32; + w |= (uint64_t) src[2] << 40; + w |= (uint64_t) src[1] << 48; + w |= (uint64_t) src[0] << 56; + return w; +#endif +} + +#define STORE64_BE(DST, W) store64_be((DST), (W)) +static inline void +store64_be(uint8_t dst[8], uint64_t w) +{ +#ifdef NATIVE_BIG_ENDIAN + memcpy(dst, &w, sizeof w); +#else + dst[7] = (uint8_t) w; w >>= 8; + dst[6] = (uint8_t) w; w >>= 8; + dst[5] = (uint8_t) w; w >>= 8; + dst[4] = (uint8_t) w; w >>= 8; + dst[3] = (uint8_t) w; w >>= 8; + dst[2] = (uint8_t) w; w >>= 8; + dst[1] = (uint8_t) w; w >>= 8; + dst[0] = (uint8_t) w; +#endif +} + +#define LOAD32_BE(SRC) load32_be(SRC) +static inline uint32_t +load32_be(const uint8_t src[4]) +{ +#ifdef NATIVE_BIG_ENDIAN + uint32_t w; + memcpy(&w, src, sizeof w); + return w; +#else + uint32_t w = (uint32_t) src[3]; + w |= (uint32_t) src[2] << 8; + w |= (uint32_t) src[1] << 16; + w |= (uint32_t) src[0] << 24; + return w; +#endif +} + +#define STORE32_BE(DST, W) store32_be((DST), (W)) +static inline void +store32_be(uint8_t dst[4], uint32_t w) +{ +#ifdef NATIVE_BIG_ENDIAN + memcpy(dst, &w, sizeof w); +#else + dst[3] = (uint8_t) w; w >>= 8; + dst[2] = (uint8_t) w; w >>= 8; + dst[1] = (uint8_t) w; w >>= 8; + dst[0] = (uint8_t) w; +#endif +} + +#define XOR_BUF(OUT, IN, N) xor_buf((OUT), (IN), (N)) +static inline void +xor_buf(unsigned char *out, const unsigned char *in, size_t n) +{ + size_t i; + + for (i = 0; i < n; i++) { + out[i] ^= in[i]; + } +} + +#ifndef __GNUC__ +# ifdef __attribute__ +# undef __attribute__ +# endif +# define __attribute__(a) +#endif + +#ifndef CRYPTO_ALIGN +# if defined(__INTEL_COMPILER) || defined(_MSC_VER) +# define CRYPTO_ALIGN(x) __declspec(align(x)) +# else +# define CRYPTO_ALIGN(x) __attribute__ ((aligned(x))) +# endif +#endif + +#if defined(_MSC_VER) && \ + (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)) + +# include + +# define HAVE_INTRIN_H 1 +# define HAVE_MMINTRIN_H 1 +# define HAVE_EMMINTRIN_H 1 +# define HAVE_PMMINTRIN_H 1 +# define HAVE_TMMINTRIN_H 1 +# define HAVE_SMMINTRIN_H 1 +# define HAVE_AVXINTRIN_H 1 +# if _MSC_VER >= 1600 +# define HAVE_WMMINTRIN_H 1 +# endif +# if _MSC_VER >= 1700 && defined(_M_X64) +# define HAVE_AVX2INTRIN_H 1 +# endif +#elif defined(HAVE_INTRIN_H) +# include +#endif + +#ifdef HAVE_LIBCTGRIND +extern void ct_poison (const void *, size_t); +extern void ct_unpoison(const void *, size_t); +# define POISON(X, L) ct_poison((X), (L)) +# define UNPOISON(X, L) ct_unpoison((X), (L)) +#else +# define POISON(X, L) (void) 0 +# define UNPOISON(X, L) (void) 0 +#endif + +#endif diff --git a/src/3rdparty/sodium/private/ed25519_ref10.h b/src/3rdparty/sodium/private/ed25519_ref10.h new file mode 100644 index 0000000..42fcd98 --- /dev/null +++ b/src/3rdparty/sodium/private/ed25519_ref10.h @@ -0,0 +1,125 @@ +#ifndef ed25519_ref10_H +#define ed25519_ref10_H + +#include +#include + +/* + fe means field element. + Here the field is \Z/(2^255-19). + */ + +#ifdef HAVE_TI_MODE +typedef uint64_t fe25519[5]; +#else +typedef int32_t fe25519[10]; +#endif + +void fe25519_invert(fe25519 out, const fe25519 z); +void fe25519_frombytes(fe25519 h, const unsigned char *s); +void fe25519_tobytes(unsigned char *s, const fe25519 h); + +#ifdef HAVE_TI_MODE +# include "ed25519_ref10_fe_51.h" +#else +# include "ed25519_ref10_fe_25_5.h" +#endif + + +/* + ge means group element. + + Here the group is the set of pairs (x,y) of field elements + satisfying -x^2 + y^2 = 1 + d x^2y^2 + where d = -121665/121666. + + Representations: + ge25519_p2 (projective): (X:Y:Z) satisfying x=X/Z, y=Y/Z + ge25519_p3 (extended): (X:Y:Z:T) satisfying x=X/Z, y=Y/Z, XY=ZT + ge25519_p1p1 (completed): ((X:Z),(Y:T)) satisfying x=X/Z, y=Y/T + ge25519_precomp (Duif): (y+x,y-x,2dxy) + */ + +typedef struct { + fe25519 X; + fe25519 Y; + fe25519 Z; +} ge25519_p2; + +typedef struct { + fe25519 X; + fe25519 Y; + fe25519 Z; + fe25519 T; +} ge25519_p3; + +typedef struct { + fe25519 X; + fe25519 Y; + fe25519 Z; + fe25519 T; +} ge25519_p1p1; + +typedef struct { + fe25519 yplusx; + fe25519 yminusx; + fe25519 xy2d; +} ge25519_precomp; + +typedef struct { + fe25519 YplusX; + fe25519 YminusX; + fe25519 Z; + fe25519 T2d; +} ge25519_cached; + +void ge25519_tobytes(unsigned char *s, const ge25519_p2 *h); + +void ge25519_p3_tobytes(unsigned char *s, const ge25519_p3 *h); + +int ge25519_frombytes(ge25519_p3 *h, const unsigned char *s); + +int ge25519_frombytes_negate_vartime(ge25519_p3 *h, const unsigned char *s); + +void ge25519_p3_to_cached(ge25519_cached *r, const ge25519_p3 *p); + +void ge25519_p1p1_to_p2(ge25519_p2 *r, const ge25519_p1p1 *p); + +void ge25519_p1p1_to_p3(ge25519_p3 *r, const ge25519_p1p1 *p); + +void ge25519_add(ge25519_p1p1 *r, const ge25519_p3 *p, const ge25519_cached *q); + +void ge25519_sub(ge25519_p1p1 *r, const ge25519_p3 *p, const ge25519_cached *q); + +void ge25519_scalarmult_base(ge25519_p3 *h, const unsigned char *a); + +void ge25519_double_scalarmult_vartime(ge25519_p2 *r, const unsigned char *a, + const ge25519_p3 *A, + const unsigned char *b); + +void ge25519_scalarmult(ge25519_p3 *h, const unsigned char *a, + const ge25519_p3 *p); + +int ge25519_is_canonical(const unsigned char *s); + +int ge25519_is_on_curve(const ge25519_p3 *p); + +int ge25519_is_on_main_subgroup(const ge25519_p3 *p); + +int ge25519_has_small_order(const unsigned char s[32]); + +void ge25519_from_uniform(unsigned char s[32], const unsigned char r[32]); + +/* + The set of scalars is \Z/l + where l = 2^252 + 27742317777372353535851937790883648493. + */ + +void sc25519_reduce(unsigned char *s); + +void sc25519_muladd(unsigned char *s, const unsigned char *a, + const unsigned char *b, const unsigned char *c); + +int sc25519_is_canonical(const unsigned char *s); + +#endif diff --git a/src/3rdparty/sodium/private/ed25519_ref10_fe_25_5.h b/src/3rdparty/sodium/private/ed25519_ref10_fe_25_5.h new file mode 100644 index 0000000..5a0b614 --- /dev/null +++ b/src/3rdparty/sodium/private/ed25519_ref10_fe_25_5.h @@ -0,0 +1,1050 @@ +#include + +#include "private/common.h" +#include "utils.h" + +/* + h = 0 + */ + +static inline void +fe25519_0(fe25519 h) +{ + memset(&h[0], 0, 10 * sizeof h[0]); +} + +/* + h = 1 + */ + +static inline void +fe25519_1(fe25519 h) +{ + h[0] = 1; + h[1] = 0; + memset(&h[2], 0, 8 * sizeof h[0]); +} + +/* + h = f + g + Can overlap h with f or g. + * + Preconditions: + |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. + |g| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. + * + Postconditions: + |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. + */ + +static inline void +fe25519_add(fe25519 h, const fe25519 f, const fe25519 g) +{ + int32_t h0 = f[0] + g[0]; + int32_t h1 = f[1] + g[1]; + int32_t h2 = f[2] + g[2]; + int32_t h3 = f[3] + g[3]; + int32_t h4 = f[4] + g[4]; + int32_t h5 = f[5] + g[5]; + int32_t h6 = f[6] + g[6]; + int32_t h7 = f[7] + g[7]; + int32_t h8 = f[8] + g[8]; + int32_t h9 = f[9] + g[9]; + + h[0] = h0; + h[1] = h1; + h[2] = h2; + h[3] = h3; + h[4] = h4; + h[5] = h5; + h[6] = h6; + h[7] = h7; + h[8] = h8; + h[9] = h9; +} + +/* + h = f - g + Can overlap h with f or g. + * + Preconditions: + |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. + |g| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. + * + Postconditions: + |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. + */ + +static void +fe25519_sub(fe25519 h, const fe25519 f, const fe25519 g) +{ + int32_t h0 = f[0] - g[0]; + int32_t h1 = f[1] - g[1]; + int32_t h2 = f[2] - g[2]; + int32_t h3 = f[3] - g[3]; + int32_t h4 = f[4] - g[4]; + int32_t h5 = f[5] - g[5]; + int32_t h6 = f[6] - g[6]; + int32_t h7 = f[7] - g[7]; + int32_t h8 = f[8] - g[8]; + int32_t h9 = f[9] - g[9]; + + h[0] = h0; + h[1] = h1; + h[2] = h2; + h[3] = h3; + h[4] = h4; + h[5] = h5; + h[6] = h6; + h[7] = h7; + h[8] = h8; + h[9] = h9; +} + +/* + h = -f + * + Preconditions: + |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. + * + Postconditions: + |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc. + */ + +static inline void +fe25519_neg(fe25519 h, const fe25519 f) +{ + int32_t h0 = -f[0]; + int32_t h1 = -f[1]; + int32_t h2 = -f[2]; + int32_t h3 = -f[3]; + int32_t h4 = -f[4]; + int32_t h5 = -f[5]; + int32_t h6 = -f[6]; + int32_t h7 = -f[7]; + int32_t h8 = -f[8]; + int32_t h9 = -f[9]; + + h[0] = h0; + h[1] = h1; + h[2] = h2; + h[3] = h3; + h[4] = h4; + h[5] = h5; + h[6] = h6; + h[7] = h7; + h[8] = h8; + h[9] = h9; +} + +/* + Replace (f,g) with (g,g) if b == 1; + replace (f,g) with (f,g) if b == 0. + * + Preconditions: b in {0,1}. + */ + +static void +fe25519_cmov(fe25519 f, const fe25519 g, unsigned int b) +{ + const uint32_t mask = (uint32_t) (-(int32_t) b); + + int32_t f0 = f[0]; + int32_t f1 = f[1]; + int32_t f2 = f[2]; + int32_t f3 = f[3]; + int32_t f4 = f[4]; + int32_t f5 = f[5]; + int32_t f6 = f[6]; + int32_t f7 = f[7]; + int32_t f8 = f[8]; + int32_t f9 = f[9]; + + int32_t x0 = f0 ^ g[0]; + int32_t x1 = f1 ^ g[1]; + int32_t x2 = f2 ^ g[2]; + int32_t x3 = f3 ^ g[3]; + int32_t x4 = f4 ^ g[4]; + int32_t x5 = f5 ^ g[5]; + int32_t x6 = f6 ^ g[6]; + int32_t x7 = f7 ^ g[7]; + int32_t x8 = f8 ^ g[8]; + int32_t x9 = f9 ^ g[9]; + + x0 &= mask; + x1 &= mask; + x2 &= mask; + x3 &= mask; + x4 &= mask; + x5 &= mask; + x6 &= mask; + x7 &= mask; + x8 &= mask; + x9 &= mask; + + f[0] = f0 ^ x0; + f[1] = f1 ^ x1; + f[2] = f2 ^ x2; + f[3] = f3 ^ x3; + f[4] = f4 ^ x4; + f[5] = f5 ^ x5; + f[6] = f6 ^ x6; + f[7] = f7 ^ x7; + f[8] = f8 ^ x8; + f[9] = f9 ^ x9; +} + +static void +fe25519_cswap(fe25519 f, fe25519 g, unsigned int b) +{ + const uint32_t mask = (uint32_t) (-(int64_t) b); + + int32_t f0 = f[0]; + int32_t f1 = f[1]; + int32_t f2 = f[2]; + int32_t f3 = f[3]; + int32_t f4 = f[4]; + int32_t f5 = f[5]; + int32_t f6 = f[6]; + int32_t f7 = f[7]; + int32_t f8 = f[8]; + int32_t f9 = f[9]; + + int32_t g0 = g[0]; + int32_t g1 = g[1]; + int32_t g2 = g[2]; + int32_t g3 = g[3]; + int32_t g4 = g[4]; + int32_t g5 = g[5]; + int32_t g6 = g[6]; + int32_t g7 = g[7]; + int32_t g8 = g[8]; + int32_t g9 = g[9]; + + int32_t x0 = f0 ^ g0; + int32_t x1 = f1 ^ g1; + int32_t x2 = f2 ^ g2; + int32_t x3 = f3 ^ g3; + int32_t x4 = f4 ^ g4; + int32_t x5 = f5 ^ g5; + int32_t x6 = f6 ^ g6; + int32_t x7 = f7 ^ g7; + int32_t x8 = f8 ^ g8; + int32_t x9 = f9 ^ g9; + + x0 &= mask; + x1 &= mask; + x2 &= mask; + x3 &= mask; + x4 &= mask; + x5 &= mask; + x6 &= mask; + x7 &= mask; + x8 &= mask; + x9 &= mask; + + f[0] = f0 ^ x0; + f[1] = f1 ^ x1; + f[2] = f2 ^ x2; + f[3] = f3 ^ x3; + f[4] = f4 ^ x4; + f[5] = f5 ^ x5; + f[6] = f6 ^ x6; + f[7] = f7 ^ x7; + f[8] = f8 ^ x8; + f[9] = f9 ^ x9; + + g[0] = g0 ^ x0; + g[1] = g1 ^ x1; + g[2] = g2 ^ x2; + g[3] = g3 ^ x3; + g[4] = g4 ^ x4; + g[5] = g5 ^ x5; + g[6] = g6 ^ x6; + g[7] = g7 ^ x7; + g[8] = g8 ^ x8; + g[9] = g9 ^ x9; +} + +/* + h = f + */ + +static inline void +fe25519_copy(fe25519 h, const fe25519 f) +{ + int32_t f0 = f[0]; + int32_t f1 = f[1]; + int32_t f2 = f[2]; + int32_t f3 = f[3]; + int32_t f4 = f[4]; + int32_t f5 = f[5]; + int32_t f6 = f[6]; + int32_t f7 = f[7]; + int32_t f8 = f[8]; + int32_t f9 = f[9]; + + h[0] = f0; + h[1] = f1; + h[2] = f2; + h[3] = f3; + h[4] = f4; + h[5] = f5; + h[6] = f6; + h[7] = f7; + h[8] = f8; + h[9] = f9; +} + +/* + return 1 if f is in {1,3,5,...,q-2} + return 0 if f is in {0,2,4,...,q-1} + + Preconditions: + |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. + */ + +static inline int +fe25519_isnegative(const fe25519 f) +{ + unsigned char s[32]; + + fe25519_tobytes(s, f); + + return s[0] & 1; +} + +/* + return 1 if f == 0 + return 0 if f != 0 + + Preconditions: + |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc. + */ + +static inline int +fe25519_iszero(const fe25519 f) +{ + unsigned char s[32]; + + fe25519_tobytes(s, f); + + return sodium_is_zero(s, 32); +} + +/* + h = f * g + Can overlap h with f or g. + * + Preconditions: + |f| bounded by 1.65*2^26,1.65*2^25,1.65*2^26,1.65*2^25,etc. + |g| bounded by 1.65*2^26,1.65*2^25,1.65*2^26,1.65*2^25,etc. + * + Postconditions: + |h| bounded by 1.01*2^25,1.01*2^24,1.01*2^25,1.01*2^24,etc. + */ + +/* + Notes on implementation strategy: + * + Using schoolbook multiplication. + Karatsuba would save a little in some cost models. + * + Most multiplications by 2 and 19 are 32-bit precomputations; + cheaper than 64-bit postcomputations. + * + There is one remaining multiplication by 19 in the carry chain; + one *19 precomputation can be merged into this, + but the resulting data flow is considerably less clean. + * + There are 12 carries below. + 10 of them are 2-way parallelizable and vectorizable. + Can get away with 11 carries, but then data flow is much deeper. + * + With tighter constraints on inputs can squeeze carries into int32. + */ + +static void +fe25519_mul(fe25519 h, const fe25519 f, const fe25519 g) +{ + int32_t f0 = f[0]; + int32_t f1 = f[1]; + int32_t f2 = f[2]; + int32_t f3 = f[3]; + int32_t f4 = f[4]; + int32_t f5 = f[5]; + int32_t f6 = f[6]; + int32_t f7 = f[7]; + int32_t f8 = f[8]; + int32_t f9 = f[9]; + + int32_t g0 = g[0]; + int32_t g1 = g[1]; + int32_t g2 = g[2]; + int32_t g3 = g[3]; + int32_t g4 = g[4]; + int32_t g5 = g[5]; + int32_t g6 = g[6]; + int32_t g7 = g[7]; + int32_t g8 = g[8]; + int32_t g9 = g[9]; + + int32_t g1_19 = 19 * g1; /* 1.959375*2^29 */ + int32_t g2_19 = 19 * g2; /* 1.959375*2^30; still ok */ + int32_t g3_19 = 19 * g3; + int32_t g4_19 = 19 * g4; + int32_t g5_19 = 19 * g5; + int32_t g6_19 = 19 * g6; + int32_t g7_19 = 19 * g7; + int32_t g8_19 = 19 * g8; + int32_t g9_19 = 19 * g9; + int32_t f1_2 = 2 * f1; + int32_t f3_2 = 2 * f3; + int32_t f5_2 = 2 * f5; + int32_t f7_2 = 2 * f7; + int32_t f9_2 = 2 * f9; + + int64_t f0g0 = f0 * (int64_t) g0; + int64_t f0g1 = f0 * (int64_t) g1; + int64_t f0g2 = f0 * (int64_t) g2; + int64_t f0g3 = f0 * (int64_t) g3; + int64_t f0g4 = f0 * (int64_t) g4; + int64_t f0g5 = f0 * (int64_t) g5; + int64_t f0g6 = f0 * (int64_t) g6; + int64_t f0g7 = f0 * (int64_t) g7; + int64_t f0g8 = f0 * (int64_t) g8; + int64_t f0g9 = f0 * (int64_t) g9; + int64_t f1g0 = f1 * (int64_t) g0; + int64_t f1g1_2 = f1_2 * (int64_t) g1; + int64_t f1g2 = f1 * (int64_t) g2; + int64_t f1g3_2 = f1_2 * (int64_t) g3; + int64_t f1g4 = f1 * (int64_t) g4; + int64_t f1g5_2 = f1_2 * (int64_t) g5; + int64_t f1g6 = f1 * (int64_t) g6; + int64_t f1g7_2 = f1_2 * (int64_t) g7; + int64_t f1g8 = f1 * (int64_t) g8; + int64_t f1g9_38 = f1_2 * (int64_t) g9_19; + int64_t f2g0 = f2 * (int64_t) g0; + int64_t f2g1 = f2 * (int64_t) g1; + int64_t f2g2 = f2 * (int64_t) g2; + int64_t f2g3 = f2 * (int64_t) g3; + int64_t f2g4 = f2 * (int64_t) g4; + int64_t f2g5 = f2 * (int64_t) g5; + int64_t f2g6 = f2 * (int64_t) g6; + int64_t f2g7 = f2 * (int64_t) g7; + int64_t f2g8_19 = f2 * (int64_t) g8_19; + int64_t f2g9_19 = f2 * (int64_t) g9_19; + int64_t f3g0 = f3 * (int64_t) g0; + int64_t f3g1_2 = f3_2 * (int64_t) g1; + int64_t f3g2 = f3 * (int64_t) g2; + int64_t f3g3_2 = f3_2 * (int64_t) g3; + int64_t f3g4 = f3 * (int64_t) g4; + int64_t f3g5_2 = f3_2 * (int64_t) g5; + int64_t f3g6 = f3 * (int64_t) g6; + int64_t f3g7_38 = f3_2 * (int64_t) g7_19; + int64_t f3g8_19 = f3 * (int64_t) g8_19; + int64_t f3g9_38 = f3_2 * (int64_t) g9_19; + int64_t f4g0 = f4 * (int64_t) g0; + int64_t f4g1 = f4 * (int64_t) g1; + int64_t f4g2 = f4 * (int64_t) g2; + int64_t f4g3 = f4 * (int64_t) g3; + int64_t f4g4 = f4 * (int64_t) g4; + int64_t f4g5 = f4 * (int64_t) g5; + int64_t f4g6_19 = f4 * (int64_t) g6_19; + int64_t f4g7_19 = f4 * (int64_t) g7_19; + int64_t f4g8_19 = f4 * (int64_t) g8_19; + int64_t f4g9_19 = f4 * (int64_t) g9_19; + int64_t f5g0 = f5 * (int64_t) g0; + int64_t f5g1_2 = f5_2 * (int64_t) g1; + int64_t f5g2 = f5 * (int64_t) g2; + int64_t f5g3_2 = f5_2 * (int64_t) g3; + int64_t f5g4 = f5 * (int64_t) g4; + int64_t f5g5_38 = f5_2 * (int64_t) g5_19; + int64_t f5g6_19 = f5 * (int64_t) g6_19; + int64_t f5g7_38 = f5_2 * (int64_t) g7_19; + int64_t f5g8_19 = f5 * (int64_t) g8_19; + int64_t f5g9_38 = f5_2 * (int64_t) g9_19; + int64_t f6g0 = f6 * (int64_t) g0; + int64_t f6g1 = f6 * (int64_t) g1; + int64_t f6g2 = f6 * (int64_t) g2; + int64_t f6g3 = f6 * (int64_t) g3; + int64_t f6g4_19 = f6 * (int64_t) g4_19; + int64_t f6g5_19 = f6 * (int64_t) g5_19; + int64_t f6g6_19 = f6 * (int64_t) g6_19; + int64_t f6g7_19 = f6 * (int64_t) g7_19; + int64_t f6g8_19 = f6 * (int64_t) g8_19; + int64_t f6g9_19 = f6 * (int64_t) g9_19; + int64_t f7g0 = f7 * (int64_t) g0; + int64_t f7g1_2 = f7_2 * (int64_t) g1; + int64_t f7g2 = f7 * (int64_t) g2; + int64_t f7g3_38 = f7_2 * (int64_t) g3_19; + int64_t f7g4_19 = f7 * (int64_t) g4_19; + int64_t f7g5_38 = f7_2 * (int64_t) g5_19; + int64_t f7g6_19 = f7 * (int64_t) g6_19; + int64_t f7g7_38 = f7_2 * (int64_t) g7_19; + int64_t f7g8_19 = f7 * (int64_t) g8_19; + int64_t f7g9_38 = f7_2 * (int64_t) g9_19; + int64_t f8g0 = f8 * (int64_t) g0; + int64_t f8g1 = f8 * (int64_t) g1; + int64_t f8g2_19 = f8 * (int64_t) g2_19; + int64_t f8g3_19 = f8 * (int64_t) g3_19; + int64_t f8g4_19 = f8 * (int64_t) g4_19; + int64_t f8g5_19 = f8 * (int64_t) g5_19; + int64_t f8g6_19 = f8 * (int64_t) g6_19; + int64_t f8g7_19 = f8 * (int64_t) g7_19; + int64_t f8g8_19 = f8 * (int64_t) g8_19; + int64_t f8g9_19 = f8 * (int64_t) g9_19; + int64_t f9g0 = f9 * (int64_t) g0; + int64_t f9g1_38 = f9_2 * (int64_t) g1_19; + int64_t f9g2_19 = f9 * (int64_t) g2_19; + int64_t f9g3_38 = f9_2 * (int64_t) g3_19; + int64_t f9g4_19 = f9 * (int64_t) g4_19; + int64_t f9g5_38 = f9_2 * (int64_t) g5_19; + int64_t f9g6_19 = f9 * (int64_t) g6_19; + int64_t f9g7_38 = f9_2 * (int64_t) g7_19; + int64_t f9g8_19 = f9 * (int64_t) g8_19; + int64_t f9g9_38 = f9_2 * (int64_t) g9_19; + + int64_t h0 = f0g0 + f1g9_38 + f2g8_19 + f3g7_38 + f4g6_19 + f5g5_38 + + f6g4_19 + f7g3_38 + f8g2_19 + f9g1_38; + int64_t h1 = f0g1 + f1g0 + f2g9_19 + f3g8_19 + f4g7_19 + f5g6_19 + f6g5_19 + + f7g4_19 + f8g3_19 + f9g2_19; + int64_t h2 = f0g2 + f1g1_2 + f2g0 + f3g9_38 + f4g8_19 + f5g7_38 + f6g6_19 + + f7g5_38 + f8g4_19 + f9g3_38; + int64_t h3 = f0g3 + f1g2 + f2g1 + f3g0 + f4g9_19 + f5g8_19 + f6g7_19 + + f7g6_19 + f8g5_19 + f9g4_19; + int64_t h4 = f0g4 + f1g3_2 + f2g2 + f3g1_2 + f4g0 + f5g9_38 + f6g8_19 + + f7g7_38 + f8g6_19 + f9g5_38; + int64_t h5 = f0g5 + f1g4 + f2g3 + f3g2 + f4g1 + f5g0 + f6g9_19 + f7g8_19 + + f8g7_19 + f9g6_19; + int64_t h6 = f0g6 + f1g5_2 + f2g4 + f3g3_2 + f4g2 + f5g1_2 + f6g0 + + f7g9_38 + f8g8_19 + f9g7_38; + int64_t h7 = f0g7 + f1g6 + f2g5 + f3g4 + f4g3 + f5g2 + f6g1 + f7g0 + + f8g9_19 + f9g8_19; + int64_t h8 = f0g8 + f1g7_2 + f2g6 + f3g5_2 + f4g4 + f5g3_2 + f6g2 + f7g1_2 + + f8g0 + f9g9_38; + int64_t h9 = + f0g9 + f1g8 + f2g7 + f3g6 + f4g5 + f5g4 + f6g3 + f7g2 + f8g1 + f9g0; + + int64_t carry0; + int64_t carry1; + int64_t carry2; + int64_t carry3; + int64_t carry4; + int64_t carry5; + int64_t carry6; + int64_t carry7; + int64_t carry8; + int64_t carry9; + + /* + |h0| <= (1.65*1.65*2^52*(1+19+19+19+19)+1.65*1.65*2^50*(38+38+38+38+38)) + i.e. |h0| <= 1.4*2^60; narrower ranges for h2, h4, h6, h8 + |h1| <= (1.65*1.65*2^51*(1+1+19+19+19+19+19+19+19+19)) + i.e. |h1| <= 1.7*2^59; narrower ranges for h3, h5, h7, h9 + */ + + carry0 = (h0 + (int64_t)(1L << 25)) >> 26; + h1 += carry0; + h0 -= carry0 * ((uint64_t) 1L << 26); + carry4 = (h4 + (int64_t)(1L << 25)) >> 26; + h5 += carry4; + h4 -= carry4 * ((uint64_t) 1L << 26); + /* |h0| <= 2^25 */ + /* |h4| <= 2^25 */ + /* |h1| <= 1.71*2^59 */ + /* |h5| <= 1.71*2^59 */ + + carry1 = (h1 + (int64_t)(1L << 24)) >> 25; + h2 += carry1; + h1 -= carry1 * ((uint64_t) 1L << 25); + carry5 = (h5 + (int64_t)(1L << 24)) >> 25; + h6 += carry5; + h5 -= carry5 * ((uint64_t) 1L << 25); + /* |h1| <= 2^24; from now on fits into int32 */ + /* |h5| <= 2^24; from now on fits into int32 */ + /* |h2| <= 1.41*2^60 */ + /* |h6| <= 1.41*2^60 */ + + carry2 = (h2 + (int64_t)(1L << 25)) >> 26; + h3 += carry2; + h2 -= carry2 * ((uint64_t) 1L << 26); + carry6 = (h6 + (int64_t)(1L << 25)) >> 26; + h7 += carry6; + h6 -= carry6 * ((uint64_t) 1L << 26); + /* |h2| <= 2^25; from now on fits into int32 unchanged */ + /* |h6| <= 2^25; from now on fits into int32 unchanged */ + /* |h3| <= 1.71*2^59 */ + /* |h7| <= 1.71*2^59 */ + + carry3 = (h3 + (int64_t)(1L << 24)) >> 25; + h4 += carry3; + h3 -= carry3 * ((uint64_t) 1L << 25); + carry7 = (h7 + (int64_t)(1L << 24)) >> 25; + h8 += carry7; + h7 -= carry7 * ((uint64_t) 1L << 25); + /* |h3| <= 2^24; from now on fits into int32 unchanged */ + /* |h7| <= 2^24; from now on fits into int32 unchanged */ + /* |h4| <= 1.72*2^34 */ + /* |h8| <= 1.41*2^60 */ + + carry4 = (h4 + (int64_t)(1L << 25)) >> 26; + h5 += carry4; + h4 -= carry4 * ((uint64_t) 1L << 26); + carry8 = (h8 + (int64_t)(1L << 25)) >> 26; + h9 += carry8; + h8 -= carry8 * ((uint64_t) 1L << 26); + /* |h4| <= 2^25; from now on fits into int32 unchanged */ + /* |h8| <= 2^25; from now on fits into int32 unchanged */ + /* |h5| <= 1.01*2^24 */ + /* |h9| <= 1.71*2^59 */ + + carry9 = (h9 + (int64_t)(1L << 24)) >> 25; + h0 += carry9 * 19; + h9 -= carry9 * ((uint64_t) 1L << 25); + /* |h9| <= 2^24; from now on fits into int32 unchanged */ + /* |h0| <= 1.1*2^39 */ + + carry0 = (h0 + (int64_t)(1L << 25)) >> 26; + h1 += carry0; + h0 -= carry0 * ((uint64_t) 1L << 26); + /* |h0| <= 2^25; from now on fits into int32 unchanged */ + /* |h1| <= 1.01*2^24 */ + + h[0] = (int32_t) h0; + h[1] = (int32_t) h1; + h[2] = (int32_t) h2; + h[3] = (int32_t) h3; + h[4] = (int32_t) h4; + h[5] = (int32_t) h5; + h[6] = (int32_t) h6; + h[7] = (int32_t) h7; + h[8] = (int32_t) h8; + h[9] = (int32_t) h9; +} + +/* + h = f * f + Can overlap h with f. + * + Preconditions: + |f| bounded by 1.65*2^26,1.65*2^25,1.65*2^26,1.65*2^25,etc. + * + Postconditions: + |h| bounded by 1.01*2^25,1.01*2^24,1.01*2^25,1.01*2^24,etc. + */ + +static void +fe25519_sq(fe25519 h, const fe25519 f) +{ + int32_t f0 = f[0]; + int32_t f1 = f[1]; + int32_t f2 = f[2]; + int32_t f3 = f[3]; + int32_t f4 = f[4]; + int32_t f5 = f[5]; + int32_t f6 = f[6]; + int32_t f7 = f[7]; + int32_t f8 = f[8]; + int32_t f9 = f[9]; + + int32_t f0_2 = 2 * f0; + int32_t f1_2 = 2 * f1; + int32_t f2_2 = 2 * f2; + int32_t f3_2 = 2 * f3; + int32_t f4_2 = 2 * f4; + int32_t f5_2 = 2 * f5; + int32_t f6_2 = 2 * f6; + int32_t f7_2 = 2 * f7; + int32_t f5_38 = 38 * f5; /* 1.959375*2^30 */ + int32_t f6_19 = 19 * f6; /* 1.959375*2^30 */ + int32_t f7_38 = 38 * f7; /* 1.959375*2^30 */ + int32_t f8_19 = 19 * f8; /* 1.959375*2^30 */ + int32_t f9_38 = 38 * f9; /* 1.959375*2^30 */ + + int64_t f0f0 = f0 * (int64_t) f0; + int64_t f0f1_2 = f0_2 * (int64_t) f1; + int64_t f0f2_2 = f0_2 * (int64_t) f2; + int64_t f0f3_2 = f0_2 * (int64_t) f3; + int64_t f0f4_2 = f0_2 * (int64_t) f4; + int64_t f0f5_2 = f0_2 * (int64_t) f5; + int64_t f0f6_2 = f0_2 * (int64_t) f6; + int64_t f0f7_2 = f0_2 * (int64_t) f7; + int64_t f0f8_2 = f0_2 * (int64_t) f8; + int64_t f0f9_2 = f0_2 * (int64_t) f9; + int64_t f1f1_2 = f1_2 * (int64_t) f1; + int64_t f1f2_2 = f1_2 * (int64_t) f2; + int64_t f1f3_4 = f1_2 * (int64_t) f3_2; + int64_t f1f4_2 = f1_2 * (int64_t) f4; + int64_t f1f5_4 = f1_2 * (int64_t) f5_2; + int64_t f1f6_2 = f1_2 * (int64_t) f6; + int64_t f1f7_4 = f1_2 * (int64_t) f7_2; + int64_t f1f8_2 = f1_2 * (int64_t) f8; + int64_t f1f9_76 = f1_2 * (int64_t) f9_38; + int64_t f2f2 = f2 * (int64_t) f2; + int64_t f2f3_2 = f2_2 * (int64_t) f3; + int64_t f2f4_2 = f2_2 * (int64_t) f4; + int64_t f2f5_2 = f2_2 * (int64_t) f5; + int64_t f2f6_2 = f2_2 * (int64_t) f6; + int64_t f2f7_2 = f2_2 * (int64_t) f7; + int64_t f2f8_38 = f2_2 * (int64_t) f8_19; + int64_t f2f9_38 = f2 * (int64_t) f9_38; + int64_t f3f3_2 = f3_2 * (int64_t) f3; + int64_t f3f4_2 = f3_2 * (int64_t) f4; + int64_t f3f5_4 = f3_2 * (int64_t) f5_2; + int64_t f3f6_2 = f3_2 * (int64_t) f6; + int64_t f3f7_76 = f3_2 * (int64_t) f7_38; + int64_t f3f8_38 = f3_2 * (int64_t) f8_19; + int64_t f3f9_76 = f3_2 * (int64_t) f9_38; + int64_t f4f4 = f4 * (int64_t) f4; + int64_t f4f5_2 = f4_2 * (int64_t) f5; + int64_t f4f6_38 = f4_2 * (int64_t) f6_19; + int64_t f4f7_38 = f4 * (int64_t) f7_38; + int64_t f4f8_38 = f4_2 * (int64_t) f8_19; + int64_t f4f9_38 = f4 * (int64_t) f9_38; + int64_t f5f5_38 = f5 * (int64_t) f5_38; + int64_t f5f6_38 = f5_2 * (int64_t) f6_19; + int64_t f5f7_76 = f5_2 * (int64_t) f7_38; + int64_t f5f8_38 = f5_2 * (int64_t) f8_19; + int64_t f5f9_76 = f5_2 * (int64_t) f9_38; + int64_t f6f6_19 = f6 * (int64_t) f6_19; + int64_t f6f7_38 = f6 * (int64_t) f7_38; + int64_t f6f8_38 = f6_2 * (int64_t) f8_19; + int64_t f6f9_38 = f6 * (int64_t) f9_38; + int64_t f7f7_38 = f7 * (int64_t) f7_38; + int64_t f7f8_38 = f7_2 * (int64_t) f8_19; + int64_t f7f9_76 = f7_2 * (int64_t) f9_38; + int64_t f8f8_19 = f8 * (int64_t) f8_19; + int64_t f8f9_38 = f8 * (int64_t) f9_38; + int64_t f9f9_38 = f9 * (int64_t) f9_38; + + int64_t h0 = f0f0 + f1f9_76 + f2f8_38 + f3f7_76 + f4f6_38 + f5f5_38; + int64_t h1 = f0f1_2 + f2f9_38 + f3f8_38 + f4f7_38 + f5f6_38; + int64_t h2 = f0f2_2 + f1f1_2 + f3f9_76 + f4f8_38 + f5f7_76 + f6f6_19; + int64_t h3 = f0f3_2 + f1f2_2 + f4f9_38 + f5f8_38 + f6f7_38; + int64_t h4 = f0f4_2 + f1f3_4 + f2f2 + f5f9_76 + f6f8_38 + f7f7_38; + int64_t h5 = f0f5_2 + f1f4_2 + f2f3_2 + f6f9_38 + f7f8_38; + int64_t h6 = f0f6_2 + f1f5_4 + f2f4_2 + f3f3_2 + f7f9_76 + f8f8_19; + int64_t h7 = f0f7_2 + f1f6_2 + f2f5_2 + f3f4_2 + f8f9_38; + int64_t h8 = f0f8_2 + f1f7_4 + f2f6_2 + f3f5_4 + f4f4 + f9f9_38; + int64_t h9 = f0f9_2 + f1f8_2 + f2f7_2 + f3f6_2 + f4f5_2; + + int64_t carry0; + int64_t carry1; + int64_t carry2; + int64_t carry3; + int64_t carry4; + int64_t carry5; + int64_t carry6; + int64_t carry7; + int64_t carry8; + int64_t carry9; + + carry0 = (h0 + (int64_t)(1L << 25)) >> 26; + h1 += carry0; + h0 -= carry0 * ((uint64_t) 1L << 26); + carry4 = (h4 + (int64_t)(1L << 25)) >> 26; + h5 += carry4; + h4 -= carry4 * ((uint64_t) 1L << 26); + + carry1 = (h1 + (int64_t)(1L << 24)) >> 25; + h2 += carry1; + h1 -= carry1 * ((uint64_t) 1L << 25); + carry5 = (h5 + (int64_t)(1L << 24)) >> 25; + h6 += carry5; + h5 -= carry5 * ((uint64_t) 1L << 25); + + carry2 = (h2 + (int64_t)(1L << 25)) >> 26; + h3 += carry2; + h2 -= carry2 * ((uint64_t) 1L << 26); + carry6 = (h6 + (int64_t)(1L << 25)) >> 26; + h7 += carry6; + h6 -= carry6 * ((uint64_t) 1L << 26); + + carry3 = (h3 + (int64_t)(1L << 24)) >> 25; + h4 += carry3; + h3 -= carry3 * ((uint64_t) 1L << 25); + carry7 = (h7 + (int64_t)(1L << 24)) >> 25; + h8 += carry7; + h7 -= carry7 * ((uint64_t) 1L << 25); + + carry4 = (h4 + (int64_t)(1L << 25)) >> 26; + h5 += carry4; + h4 -= carry4 * ((uint64_t) 1L << 26); + carry8 = (h8 + (int64_t)(1L << 25)) >> 26; + h9 += carry8; + h8 -= carry8 * ((uint64_t) 1L << 26); + + carry9 = (h9 + (int64_t)(1L << 24)) >> 25; + h0 += carry9 * 19; + h9 -= carry9 * ((uint64_t) 1L << 25); + + carry0 = (h0 + (int64_t)(1L << 25)) >> 26; + h1 += carry0; + h0 -= carry0 * ((uint64_t) 1L << 26); + + h[0] = (int32_t) h0; + h[1] = (int32_t) h1; + h[2] = (int32_t) h2; + h[3] = (int32_t) h3; + h[4] = (int32_t) h4; + h[5] = (int32_t) h5; + h[6] = (int32_t) h6; + h[7] = (int32_t) h7; + h[8] = (int32_t) h8; + h[9] = (int32_t) h9; +} + +/* + h = 2 * f * f + Can overlap h with f. + * + Preconditions: + |f| bounded by 1.65*2^26,1.65*2^25,1.65*2^26,1.65*2^25,etc. + * + Postconditions: + |h| bounded by 1.01*2^25,1.01*2^24,1.01*2^25,1.01*2^24,etc. + */ + +static void +fe25519_sq2(fe25519 h, const fe25519 f) +{ + int32_t f0 = f[0]; + int32_t f1 = f[1]; + int32_t f2 = f[2]; + int32_t f3 = f[3]; + int32_t f4 = f[4]; + int32_t f5 = f[5]; + int32_t f6 = f[6]; + int32_t f7 = f[7]; + int32_t f8 = f[8]; + int32_t f9 = f[9]; + + int32_t f0_2 = 2 * f0; + int32_t f1_2 = 2 * f1; + int32_t f2_2 = 2 * f2; + int32_t f3_2 = 2 * f3; + int32_t f4_2 = 2 * f4; + int32_t f5_2 = 2 * f5; + int32_t f6_2 = 2 * f6; + int32_t f7_2 = 2 * f7; + int32_t f5_38 = 38 * f5; /* 1.959375*2^30 */ + int32_t f6_19 = 19 * f6; /* 1.959375*2^30 */ + int32_t f7_38 = 38 * f7; /* 1.959375*2^30 */ + int32_t f8_19 = 19 * f8; /* 1.959375*2^30 */ + int32_t f9_38 = 38 * f9; /* 1.959375*2^30 */ + + int64_t f0f0 = f0 * (int64_t) f0; + int64_t f0f1_2 = f0_2 * (int64_t) f1; + int64_t f0f2_2 = f0_2 * (int64_t) f2; + int64_t f0f3_2 = f0_2 * (int64_t) f3; + int64_t f0f4_2 = f0_2 * (int64_t) f4; + int64_t f0f5_2 = f0_2 * (int64_t) f5; + int64_t f0f6_2 = f0_2 * (int64_t) f6; + int64_t f0f7_2 = f0_2 * (int64_t) f7; + int64_t f0f8_2 = f0_2 * (int64_t) f8; + int64_t f0f9_2 = f0_2 * (int64_t) f9; + int64_t f1f1_2 = f1_2 * (int64_t) f1; + int64_t f1f2_2 = f1_2 * (int64_t) f2; + int64_t f1f3_4 = f1_2 * (int64_t) f3_2; + int64_t f1f4_2 = f1_2 * (int64_t) f4; + int64_t f1f5_4 = f1_2 * (int64_t) f5_2; + int64_t f1f6_2 = f1_2 * (int64_t) f6; + int64_t f1f7_4 = f1_2 * (int64_t) f7_2; + int64_t f1f8_2 = f1_2 * (int64_t) f8; + int64_t f1f9_76 = f1_2 * (int64_t) f9_38; + int64_t f2f2 = f2 * (int64_t) f2; + int64_t f2f3_2 = f2_2 * (int64_t) f3; + int64_t f2f4_2 = f2_2 * (int64_t) f4; + int64_t f2f5_2 = f2_2 * (int64_t) f5; + int64_t f2f6_2 = f2_2 * (int64_t) f6; + int64_t f2f7_2 = f2_2 * (int64_t) f7; + int64_t f2f8_38 = f2_2 * (int64_t) f8_19; + int64_t f2f9_38 = f2 * (int64_t) f9_38; + int64_t f3f3_2 = f3_2 * (int64_t) f3; + int64_t f3f4_2 = f3_2 * (int64_t) f4; + int64_t f3f5_4 = f3_2 * (int64_t) f5_2; + int64_t f3f6_2 = f3_2 * (int64_t) f6; + int64_t f3f7_76 = f3_2 * (int64_t) f7_38; + int64_t f3f8_38 = f3_2 * (int64_t) f8_19; + int64_t f3f9_76 = f3_2 * (int64_t) f9_38; + int64_t f4f4 = f4 * (int64_t) f4; + int64_t f4f5_2 = f4_2 * (int64_t) f5; + int64_t f4f6_38 = f4_2 * (int64_t) f6_19; + int64_t f4f7_38 = f4 * (int64_t) f7_38; + int64_t f4f8_38 = f4_2 * (int64_t) f8_19; + int64_t f4f9_38 = f4 * (int64_t) f9_38; + int64_t f5f5_38 = f5 * (int64_t) f5_38; + int64_t f5f6_38 = f5_2 * (int64_t) f6_19; + int64_t f5f7_76 = f5_2 * (int64_t) f7_38; + int64_t f5f8_38 = f5_2 * (int64_t) f8_19; + int64_t f5f9_76 = f5_2 * (int64_t) f9_38; + int64_t f6f6_19 = f6 * (int64_t) f6_19; + int64_t f6f7_38 = f6 * (int64_t) f7_38; + int64_t f6f8_38 = f6_2 * (int64_t) f8_19; + int64_t f6f9_38 = f6 * (int64_t) f9_38; + int64_t f7f7_38 = f7 * (int64_t) f7_38; + int64_t f7f8_38 = f7_2 * (int64_t) f8_19; + int64_t f7f9_76 = f7_2 * (int64_t) f9_38; + int64_t f8f8_19 = f8 * (int64_t) f8_19; + int64_t f8f9_38 = f8 * (int64_t) f9_38; + int64_t f9f9_38 = f9 * (int64_t) f9_38; + + int64_t h0 = f0f0 + f1f9_76 + f2f8_38 + f3f7_76 + f4f6_38 + f5f5_38; + int64_t h1 = f0f1_2 + f2f9_38 + f3f8_38 + f4f7_38 + f5f6_38; + int64_t h2 = f0f2_2 + f1f1_2 + f3f9_76 + f4f8_38 + f5f7_76 + f6f6_19; + int64_t h3 = f0f3_2 + f1f2_2 + f4f9_38 + f5f8_38 + f6f7_38; + int64_t h4 = f0f4_2 + f1f3_4 + f2f2 + f5f9_76 + f6f8_38 + f7f7_38; + int64_t h5 = f0f5_2 + f1f4_2 + f2f3_2 + f6f9_38 + f7f8_38; + int64_t h6 = f0f6_2 + f1f5_4 + f2f4_2 + f3f3_2 + f7f9_76 + f8f8_19; + int64_t h7 = f0f7_2 + f1f6_2 + f2f5_2 + f3f4_2 + f8f9_38; + int64_t h8 = f0f8_2 + f1f7_4 + f2f6_2 + f3f5_4 + f4f4 + f9f9_38; + int64_t h9 = f0f9_2 + f1f8_2 + f2f7_2 + f3f6_2 + f4f5_2; + + int64_t carry0; + int64_t carry1; + int64_t carry2; + int64_t carry3; + int64_t carry4; + int64_t carry5; + int64_t carry6; + int64_t carry7; + int64_t carry8; + int64_t carry9; + + h0 += h0; + h1 += h1; + h2 += h2; + h3 += h3; + h4 += h4; + h5 += h5; + h6 += h6; + h7 += h7; + h8 += h8; + h9 += h9; + + carry0 = (h0 + (int64_t)(1L << 25)) >> 26; + h1 += carry0; + h0 -= carry0 * ((uint64_t) 1L << 26); + carry4 = (h4 + (int64_t)(1L << 25)) >> 26; + h5 += carry4; + h4 -= carry4 * ((uint64_t) 1L << 26); + + carry1 = (h1 + (int64_t)(1L << 24)) >> 25; + h2 += carry1; + h1 -= carry1 * ((uint64_t) 1L << 25); + carry5 = (h5 + (int64_t)(1L << 24)) >> 25; + h6 += carry5; + h5 -= carry5 * ((uint64_t) 1L << 25); + + carry2 = (h2 + (int64_t)(1L << 25)) >> 26; + h3 += carry2; + h2 -= carry2 * ((uint64_t) 1L << 26); + carry6 = (h6 + (int64_t)(1L << 25)) >> 26; + h7 += carry6; + h6 -= carry6 * ((uint64_t) 1L << 26); + + carry3 = (h3 + (int64_t)(1L << 24)) >> 25; + h4 += carry3; + h3 -= carry3 * ((uint64_t) 1L << 25); + carry7 = (h7 + (int64_t)(1L << 24)) >> 25; + h8 += carry7; + h7 -= carry7 * ((uint64_t) 1L << 25); + + carry4 = (h4 + (int64_t)(1L << 25)) >> 26; + h5 += carry4; + h4 -= carry4 * ((uint64_t) 1L << 26); + carry8 = (h8 + (int64_t)(1L << 25)) >> 26; + h9 += carry8; + h8 -= carry8 * ((uint64_t) 1L << 26); + + carry9 = (h9 + (int64_t)(1L << 24)) >> 25; + h0 += carry9 * 19; + h9 -= carry9 * ((uint64_t) 1L << 25); + + carry0 = (h0 + (int64_t)(1L << 25)) >> 26; + h1 += carry0; + h0 -= carry0 * ((uint64_t) 1L << 26); + + h[0] = (int32_t) h0; + h[1] = (int32_t) h1; + h[2] = (int32_t) h2; + h[3] = (int32_t) h3; + h[4] = (int32_t) h4; + h[5] = (int32_t) h5; + h[6] = (int32_t) h6; + h[7] = (int32_t) h7; + h[8] = (int32_t) h8; + h[9] = (int32_t) h9; +} + +static void +fe25519_scalar_product(fe25519 h, const fe25519 f, uint32_t n) +{ + int64_t sn = (int64_t) n; + int32_t f0 = f[0]; + int32_t f1 = f[1]; + int32_t f2 = f[2]; + int32_t f3 = f[3]; + int32_t f4 = f[4]; + int32_t f5 = f[5]; + int32_t f6 = f[6]; + int32_t f7 = f[7]; + int32_t f8 = f[8]; + int32_t f9 = f[9]; + int64_t h0 = f0 * sn; + int64_t h1 = f1 * sn; + int64_t h2 = f2 * sn; + int64_t h3 = f3 * sn; + int64_t h4 = f4 * sn; + int64_t h5 = f5 * sn; + int64_t h6 = f6 * sn; + int64_t h7 = f7 * sn; + int64_t h8 = f8 * sn; + int64_t h9 = f9 * sn; + int64_t carry0, carry1, carry2, carry3, carry4, carry5, carry6, carry7, + carry8, carry9; + + carry9 = (h9 + ((int64_t) 1 << 24)) >> 25; + h0 += carry9 * 19; + h9 -= carry9 * ((int64_t) 1 << 25); + carry1 = (h1 + ((int64_t) 1 << 24)) >> 25; + h2 += carry1; + h1 -= carry1 * ((int64_t) 1 << 25); + carry3 = (h3 + ((int64_t) 1 << 24)) >> 25; + h4 += carry3; + h3 -= carry3 * ((int64_t) 1 << 25); + carry5 = (h5 + ((int64_t) 1 << 24)) >> 25; + h6 += carry5; + h5 -= carry5 * ((int64_t) 1 << 25); + carry7 = (h7 + ((int64_t) 1 << 24)) >> 25; + h8 += carry7; + h7 -= carry7 * ((int64_t) 1 << 25); + + carry0 = (h0 + ((int64_t) 1 << 25)) >> 26; + h1 += carry0; + h0 -= carry0 * ((int64_t) 1 << 26); + carry2 = (h2 + ((int64_t) 1 << 25)) >> 26; + h3 += carry2; + h2 -= carry2 * ((int64_t) 1 << 26); + carry4 = (h4 + ((int64_t) 1 << 25)) >> 26; + h5 += carry4; + h4 -= carry4 * ((int64_t) 1 << 26); + carry6 = (h6 + ((int64_t) 1 << 25)) >> 26; + h7 += carry6; + h6 -= carry6 * ((int64_t) 1 << 26); + carry8 = (h8 + ((int64_t) 1 << 25)) >> 26; + h9 += carry8; + h8 -= carry8 * ((int64_t) 1 << 26); + + h[0] = (int32_t) h0; + h[1] = (int32_t) h1; + h[2] = (int32_t) h2; + h[3] = (int32_t) h3; + h[4] = (int32_t) h4; + h[5] = (int32_t) h5; + h[6] = (int32_t) h6; + h[7] = (int32_t) h7; + h[8] = (int32_t) h8; + h[9] = (int32_t) h9; +} diff --git a/src/3rdparty/sodium/private/ed25519_ref10_fe_51.h b/src/3rdparty/sodium/private/ed25519_ref10_fe_51.h new file mode 100644 index 0000000..3a30f30 --- /dev/null +++ b/src/3rdparty/sodium/private/ed25519_ref10_fe_51.h @@ -0,0 +1,518 @@ +#include + +#include "private/common.h" +#include "utils.h" + +/* + h = 0 + */ + +static inline void +fe25519_0(fe25519 h) +{ + memset(&h[0], 0, 5 * sizeof h[0]); +} + +/* + h = 1 + */ + +static inline void +fe25519_1(fe25519 h) +{ + h[0] = 1; + memset(&h[1], 0, 4 * sizeof h[0]); +} + +/* + h = f + g + Can overlap h with f or g. + */ + +static inline void +fe25519_add(fe25519 h, const fe25519 f, const fe25519 g) +{ + uint64_t h0 = f[0] + g[0]; + uint64_t h1 = f[1] + g[1]; + uint64_t h2 = f[2] + g[2]; + uint64_t h3 = f[3] + g[3]; + uint64_t h4 = f[4] + g[4]; + + h[0] = h0; + h[1] = h1; + h[2] = h2; + h[3] = h3; + h[4] = h4; +} + +/* + h = f - g + */ + +static void +fe25519_sub(fe25519 h, const fe25519 f, const fe25519 g) +{ + const uint64_t mask = 0x7ffffffffffffULL; + uint64_t h0, h1, h2, h3, h4; + + h0 = g[0]; + h1 = g[1]; + h2 = g[2]; + h3 = g[3]; + h4 = g[4]; + + h1 += h0 >> 51; + h0 &= mask; + h2 += h1 >> 51; + h1 &= mask; + h3 += h2 >> 51; + h2 &= mask; + h4 += h3 >> 51; + h3 &= mask; + h0 += 19ULL * (h4 >> 51); + h4 &= mask; + + h0 = (f[0] + 0xfffffffffffdaULL) - h0; + h1 = (f[1] + 0xffffffffffffeULL) - h1; + h2 = (f[2] + 0xffffffffffffeULL) - h2; + h3 = (f[3] + 0xffffffffffffeULL) - h3; + h4 = (f[4] + 0xffffffffffffeULL) - h4; + + h[0] = h0; + h[1] = h1; + h[2] = h2; + h[3] = h3; + h[4] = h4; +} + +/* + h = -f + */ + +static inline void +fe25519_neg(fe25519 h, const fe25519 f) +{ + fe25519 zero; + + fe25519_0(zero); + fe25519_sub(h, zero, f); +} + +/* + Replace (f,g) with (g,g) if b == 1; + replace (f,g) with (f,g) if b == 0. + * + Preconditions: b in {0,1}. + */ + +static void +fe25519_cmov(fe25519 f, const fe25519 g, unsigned int b) +{ + const uint64_t mask = (uint64_t) (-(int64_t) b); + + uint64_t f0 = f[0]; + uint64_t f1 = f[1]; + uint64_t f2 = f[2]; + uint64_t f3 = f[3]; + uint64_t f4 = f[4]; + + uint64_t x0 = f0 ^ g[0]; + uint64_t x1 = f1 ^ g[1]; + uint64_t x2 = f2 ^ g[2]; + uint64_t x3 = f3 ^ g[3]; + uint64_t x4 = f4 ^ g[4]; + + x0 &= mask; + x1 &= mask; + x2 &= mask; + x3 &= mask; + x4 &= mask; + + f[0] = f0 ^ x0; + f[1] = f1 ^ x1; + f[2] = f2 ^ x2; + f[3] = f3 ^ x3; + f[4] = f4 ^ x4; +} + +/* +Replace (f,g) with (g,f) if b == 1; +replace (f,g) with (f,g) if b == 0. + +Preconditions: b in {0,1}. +*/ + +static void +fe25519_cswap(fe25519 f, fe25519 g, unsigned int b) +{ + const uint64_t mask = (uint64_t) (-(int64_t) b); + + uint64_t f0 = f[0]; + uint64_t f1 = f[1]; + uint64_t f2 = f[2]; + uint64_t f3 = f[3]; + uint64_t f4 = f[4]; + + uint64_t g0 = g[0]; + uint64_t g1 = g[1]; + uint64_t g2 = g[2]; + uint64_t g3 = g[3]; + uint64_t g4 = g[4]; + + uint64_t x0 = f0 ^ g0; + uint64_t x1 = f1 ^ g1; + uint64_t x2 = f2 ^ g2; + uint64_t x3 = f3 ^ g3; + uint64_t x4 = f4 ^ g4; + + x0 &= mask; + x1 &= mask; + x2 &= mask; + x3 &= mask; + x4 &= mask; + + f[0] = f0 ^ x0; + f[1] = f1 ^ x1; + f[2] = f2 ^ x2; + f[3] = f3 ^ x3; + f[4] = f4 ^ x4; + + g[0] = g0 ^ x0; + g[1] = g1 ^ x1; + g[2] = g2 ^ x2; + g[3] = g3 ^ x3; + g[4] = g4 ^ x4; +} + +/* + h = f + */ + +static inline void +fe25519_copy(fe25519 h, const fe25519 f) +{ + uint64_t f0 = f[0]; + uint64_t f1 = f[1]; + uint64_t f2 = f[2]; + uint64_t f3 = f[3]; + uint64_t f4 = f[4]; + + h[0] = f0; + h[1] = f1; + h[2] = f2; + h[3] = f3; + h[4] = f4; +} + +/* + return 1 if f is in {1,3,5,...,q-2} + return 0 if f is in {0,2,4,...,q-1} + */ + +static inline int +fe25519_isnegative(const fe25519 f) +{ + unsigned char s[32]; + + fe25519_tobytes(s, f); + + return s[0] & 1; +} + +/* + return 1 if f == 0 + return 0 if f != 0 + */ + +static inline int +fe25519_iszero(const fe25519 f) +{ + unsigned char s[32]; + + fe25519_tobytes(s, f); + + return sodium_is_zero(s, 32); +} + +/* + h = f * g + Can overlap h with f or g. + */ + +static void +fe25519_mul(fe25519 h, const fe25519 f, const fe25519 g) +{ + const uint64_t mask = 0x7ffffffffffffULL; + uint128_t r0, r1, r2, r3, r4, carry; + uint64_t f0, f1, f2, f3, f4; + uint64_t f1_19, f2_19, f3_19, f4_19; + uint64_t g0, g1, g2, g3, g4; + uint64_t r00, r01, r02, r03, r04; + + f0 = f[0]; + f1 = f[1]; + f2 = f[2]; + f3 = f[3]; + f4 = f[4]; + + g0 = g[0]; + g1 = g[1]; + g2 = g[2]; + g3 = g[3]; + g4 = g[4]; + + f1_19 = 19ULL * f1; + f2_19 = 19ULL * f2; + f3_19 = 19ULL * f3; + f4_19 = 19ULL * f4; + + r0 = ((uint128_t) f0 ) * ((uint128_t) g0); + r0 += ((uint128_t) f1_19) * ((uint128_t) g4); + r0 += ((uint128_t) f2_19) * ((uint128_t) g3); + r0 += ((uint128_t) f3_19) * ((uint128_t) g2); + r0 += ((uint128_t) f4_19) * ((uint128_t) g1); + + r1 = ((uint128_t) f0 ) * ((uint128_t) g1); + r1 += ((uint128_t) f1 ) * ((uint128_t) g0); + r1 += ((uint128_t) f2_19) * ((uint128_t) g4); + r1 += ((uint128_t) f3_19) * ((uint128_t) g3); + r1 += ((uint128_t) f4_19) * ((uint128_t) g2); + + r2 = ((uint128_t) f0 ) * ((uint128_t) g2); + r2 += ((uint128_t) f1 ) * ((uint128_t) g1); + r2 += ((uint128_t) f2 ) * ((uint128_t) g0); + r2 += ((uint128_t) f3_19) * ((uint128_t) g4); + r2 += ((uint128_t) f4_19) * ((uint128_t) g3); + + r3 = ((uint128_t) f0 ) * ((uint128_t) g3); + r3 += ((uint128_t) f1 ) * ((uint128_t) g2); + r3 += ((uint128_t) f2 ) * ((uint128_t) g1); + r3 += ((uint128_t) f3 ) * ((uint128_t) g0); + r3 += ((uint128_t) f4_19) * ((uint128_t) g4); + + r4 = ((uint128_t) f0 ) * ((uint128_t) g4); + r4 += ((uint128_t) f1 ) * ((uint128_t) g3); + r4 += ((uint128_t) f2 ) * ((uint128_t) g2); + r4 += ((uint128_t) f3 ) * ((uint128_t) g1); + r4 += ((uint128_t) f4 ) * ((uint128_t) g0); + + r00 = ((uint64_t) r0) & mask; + carry = r0 >> 51; + r1 += carry; + r01 = ((uint64_t) r1) & mask; + carry = r1 >> 51; + r2 += carry; + r02 = ((uint64_t) r2) & mask; + carry = r2 >> 51; + r3 += carry; + r03 = ((uint64_t) r3) & mask; + carry = r3 >> 51; + r4 += carry; + r04 = ((uint64_t) r4) & mask; + carry = r4 >> 51; + r00 += 19ULL * (uint64_t) carry; + carry = r00 >> 51; + r00 &= mask; + r01 += (uint64_t) carry; + carry = r01 >> 51; + r01 &= mask; + r02 += (uint64_t) carry; + + h[0] = r00; + h[1] = r01; + h[2] = r02; + h[3] = r03; + h[4] = r04; +} + +/* + h = f * f + Can overlap h with f. + */ + +static void +fe25519_sq(fe25519 h, const fe25519 f) +{ + const uint64_t mask = 0x7ffffffffffffULL; + uint128_t r0, r1, r2, r3, r4, carry; + uint64_t f0, f1, f2, f3, f4; + uint64_t f0_2, f1_2, f1_38, f2_38, f3_38, f3_19, f4_19; + uint64_t r00, r01, r02, r03, r04; + + f0 = f[0]; + f1 = f[1]; + f2 = f[2]; + f3 = f[3]; + f4 = f[4]; + + f0_2 = f0 << 1; + f1_2 = f1 << 1; + + f1_38 = 38ULL * f1; + f2_38 = 38ULL * f2; + f3_38 = 38ULL * f3; + + f3_19 = 19ULL * f3; + f4_19 = 19ULL * f4; + + r0 = ((uint128_t) f0 ) * ((uint128_t) f0); + r0 += ((uint128_t) f1_38) * ((uint128_t) f4); + r0 += ((uint128_t) f2_38) * ((uint128_t) f3); + + r1 = ((uint128_t) f0_2 ) * ((uint128_t) f1); + r1 += ((uint128_t) f2_38) * ((uint128_t) f4); + r1 += ((uint128_t) f3_19) * ((uint128_t) f3); + + r2 = ((uint128_t) f0_2 ) * ((uint128_t) f2); + r2 += ((uint128_t) f1 ) * ((uint128_t) f1); + r2 += ((uint128_t) f3_38) * ((uint128_t) f4); + + r3 = ((uint128_t) f0_2 ) * ((uint128_t) f3); + r3 += ((uint128_t) f1_2 ) * ((uint128_t) f2); + r3 += ((uint128_t) f4_19) * ((uint128_t) f4); + + r4 = ((uint128_t) f0_2 ) * ((uint128_t) f4); + r4 += ((uint128_t) f1_2 ) * ((uint128_t) f3); + r4 += ((uint128_t) f2 ) * ((uint128_t) f2); + + r00 = ((uint64_t) r0) & mask; + carry = r0 >> 51; + r1 += carry; + r01 = ((uint64_t) r1) & mask; + carry = r1 >> 51; + r2 += carry; + r02 = ((uint64_t) r2) & mask; + carry = r2 >> 51; + r3 += carry; + r03 = ((uint64_t) r3) & mask; + carry = r3 >> 51; + r4 += carry; + r04 = ((uint64_t) r4) & mask; + carry = r4 >> 51; + r00 += 19ULL * (uint64_t) carry; + carry = r00 >> 51; + r00 &= mask; + r01 += (uint64_t) carry; + carry = r01 >> 51; + r01 &= mask; + r02 += (uint64_t) carry; + + h[0] = r00; + h[1] = r01; + h[2] = r02; + h[3] = r03; + h[4] = r04; +} + +/* + h = 2 * f * f + Can overlap h with f. +*/ + +static void +fe25519_sq2(fe25519 h, const fe25519 f) +{ + const uint64_t mask = 0x7ffffffffffffULL; + uint128_t r0, r1, r2, r3, r4, carry; + uint64_t f0, f1, f2, f3, f4; + uint64_t f0_2, f1_2, f1_38, f2_38, f3_38, f3_19, f4_19; + uint64_t r00, r01, r02, r03, r04; + + f0 = f[0]; + f1 = f[1]; + f2 = f[2]; + f3 = f[3]; + f4 = f[4]; + + f0_2 = f0 << 1; + f1_2 = f1 << 1; + + f1_38 = 38ULL * f1; + f2_38 = 38ULL * f2; + f3_38 = 38ULL * f3; + + f3_19 = 19ULL * f3; + f4_19 = 19ULL * f4; + + r0 = ((uint128_t) f0 ) * ((uint128_t) f0); + r0 += ((uint128_t) f1_38) * ((uint128_t) f4); + r0 += ((uint128_t) f2_38) * ((uint128_t) f3); + + r1 = ((uint128_t) f0_2 ) * ((uint128_t) f1); + r1 += ((uint128_t) f2_38) * ((uint128_t) f4); + r1 += ((uint128_t) f3_19) * ((uint128_t) f3); + + r2 = ((uint128_t) f0_2 ) * ((uint128_t) f2); + r2 += ((uint128_t) f1 ) * ((uint128_t) f1); + r2 += ((uint128_t) f3_38) * ((uint128_t) f4); + + r3 = ((uint128_t) f0_2 ) * ((uint128_t) f3); + r3 += ((uint128_t) f1_2 ) * ((uint128_t) f2); + r3 += ((uint128_t) f4_19) * ((uint128_t) f4); + + r4 = ((uint128_t) f0_2 ) * ((uint128_t) f4); + r4 += ((uint128_t) f1_2 ) * ((uint128_t) f3); + r4 += ((uint128_t) f2 ) * ((uint128_t) f2); + + r0 <<= 1; + r1 <<= 1; + r2 <<= 1; + r3 <<= 1; + r4 <<= 1; + + r00 = ((uint64_t) r0) & mask; + carry = r0 >> 51; + r1 += carry; + r01 = ((uint64_t) r1) & mask; + carry = r1 >> 51; + r2 += carry; + r02 = ((uint64_t) r2) & mask; + carry = r2 >> 51; + r3 += carry; + r03 = ((uint64_t) r3) & mask; + carry = r3 >> 51; + r4 += carry; + r04 = ((uint64_t) r4) & mask; + carry = r4 >> 51; + r00 += 19ULL * (uint64_t) carry; + carry = r00 >> 51; + r00 &= mask; + r01 += (uint64_t) carry; + carry = r01 >> 51; + r01 &= mask; + r02 += (uint64_t) carry; + + h[0] = r00; + h[1] = r01; + h[2] = r02; + h[3] = r03; + h[4] = r04; +} + +static void +fe25519_scalar_product(fe25519 h, const fe25519 f, uint32_t n) +{ + const uint64_t mask = 0x7ffffffffffffULL; + uint128_t a; + uint128_t sn = (uint128_t) n; + uint64_t h0, h1, h2, h3, h4; + + a = f[0] * sn; + h0 = ((uint64_t) a) & mask; + a = f[1] * sn + ((uint64_t) (a >> 51)); + h1 = ((uint64_t) a) & mask; + a = f[2] * sn + ((uint64_t) (a >> 51)); + h2 = ((uint64_t) a) & mask; + a = f[3] * sn + ((uint64_t) (a >> 51)); + h3 = ((uint64_t) a) & mask; + a = f[4] * sn + ((uint64_t) (a >> 51)); + h4 = ((uint64_t) a) & mask; + + h0 += (a >> 51) * 19ULL; + + h[0] = h0; + h[1] = h1; + h[2] = h2; + h[3] = h3; + h[4] = h4; +} diff --git a/src/3rdparty/sodium/private/implementations.h b/src/3rdparty/sodium/private/implementations.h new file mode 100644 index 0000000..c7237f8 --- /dev/null +++ b/src/3rdparty/sodium/private/implementations.h @@ -0,0 +1,11 @@ +#ifndef implementations_H +#define implementations_H + +int _crypto_generichash_blake2b_pick_best_implementation(void); +int _crypto_onetimeauth_poly1305_pick_best_implementation(void); +int _crypto_pwhash_argon2_pick_best_implementation(void); +int _crypto_scalarmult_curve25519_pick_best_implementation(void); +int _crypto_stream_chacha20_pick_best_implementation(void); +int _crypto_stream_salsa20_pick_best_implementation(void); + +#endif diff --git a/src/3rdparty/sodium/private/mutex.h b/src/3rdparty/sodium/private/mutex.h new file mode 100644 index 0000000..322b674 --- /dev/null +++ b/src/3rdparty/sodium/private/mutex.h @@ -0,0 +1,7 @@ +#ifndef mutex_H +#define mutex_H 1 + +extern int sodium_crit_enter(void); +extern int sodium_crit_leave(void); + +#endif diff --git a/src/3rdparty/sodium/private/sse2_64_32.h b/src/3rdparty/sodium/private/sse2_64_32.h new file mode 100644 index 0000000..d0455b4 --- /dev/null +++ b/src/3rdparty/sodium/private/sse2_64_32.h @@ -0,0 +1,50 @@ +#ifndef sse2_64_32_H +#define sse2_64_32_H 1 + +#include "common.h" + +#ifdef HAVE_INTRIN_H +# include +#endif + +#if defined(HAVE_EMMINTRIN_H) && \ + !(defined(__amd64) || defined(__amd64__) || defined(__x86_64__) || \ + defined(_M_X64) || defined(_M_AMD64)) + +# include +# include + +# ifndef _mm_set_epi64x +# define _mm_set_epi64x(Q0, Q1) sodium__mm_set_epi64x((Q0), (Q1)) +static inline __m128i +sodium__mm_set_epi64x(int64_t q1, int64_t q0) +{ + union { int64_t as64; int32_t as32[2]; } x0, x1; + x0.as64 = q0; x1.as64 = q1; + return _mm_set_epi32(x1.as32[1], x1.as32[0], x0.as32[1], x0.as32[0]); +} +# endif + +# ifndef _mm_set1_epi64x +# define _mm_set1_epi64x(Q) sodium__mm_set1_epi64x(Q) +static inline __m128i +sodium__mm_set1_epi64x(int64_t q) +{ + return _mm_set_epi64x(q, q); +} +# endif + +# ifndef _mm_cvtsi64_si128 +# define _mm_cvtsi64_si128(Q) sodium__mm_cvtsi64_si128(Q) +static inline __m128i +sodium__mm_cvtsi64_si128(int64_t q) +{ + union { int64_t as64; int32_t as32[2]; } x; + x.as64 = q; + return _mm_setr_epi32(x.as32[0], x.as32[1], 0, 0); +} +# endif + +#endif + +#endif diff --git a/src/3rdparty/sodium/randombytes.h b/src/3rdparty/sodium/randombytes.h new file mode 100644 index 0000000..d19f684 --- /dev/null +++ b/src/3rdparty/sodium/randombytes.h @@ -0,0 +1,68 @@ + +#ifndef randombytes_H +#define randombytes_H + +#include +#include + +#include + +#include "export.h" + +#ifdef __cplusplus +# ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wlong-long" +# endif +extern "C" { +#endif + +typedef struct randombytes_implementation { + const char *(*implementation_name)(void); /* required */ + uint32_t (*random)(void); /* required */ + void (*stir)(void); /* optional */ + uint32_t (*uniform)(const uint32_t upper_bound); /* optional, a default implementation will be used if NULL */ + void (*buf)(void * const buf, const size_t size); /* required */ + int (*close)(void); /* optional */ +} randombytes_implementation; + +#define randombytes_BYTES_MAX SODIUM_MIN(SODIUM_SIZE_MAX, 0xffffffffUL) + +#define randombytes_SEEDBYTES 32U +SODIUM_EXPORT +size_t randombytes_seedbytes(void); + +SODIUM_EXPORT +void randombytes_buf(void * const buf, const size_t size); + +SODIUM_EXPORT +void randombytes_buf_deterministic(void * const buf, const size_t size, + const unsigned char seed[randombytes_SEEDBYTES]); + +SODIUM_EXPORT +uint32_t randombytes_random(void); + +SODIUM_EXPORT +uint32_t randombytes_uniform(const uint32_t upper_bound); + +SODIUM_EXPORT +void randombytes_stir(void); + +SODIUM_EXPORT +int randombytes_close(void); + +SODIUM_EXPORT +int randombytes_set_implementation(randombytes_implementation *impl); + +SODIUM_EXPORT +const char *randombytes_implementation_name(void); + +/* -- NaCl compatibility interface -- */ + +SODIUM_EXPORT +void randombytes(unsigned char * const buf, const unsigned long long buf_len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/randombytes_nativeclient.h b/src/3rdparty/sodium/randombytes_nativeclient.h new file mode 100644 index 0000000..5158d8c --- /dev/null +++ b/src/3rdparty/sodium/randombytes_nativeclient.h @@ -0,0 +1,23 @@ + +#ifndef randombytes_nativeclient_H +#define randombytes_nativeclient_H + +#ifdef __native_client__ + +# include "export.h" +# include "randombytes.h" + +# ifdef __cplusplus +extern "C" { +# endif + +SODIUM_EXPORT +extern struct randombytes_implementation randombytes_nativeclient_implementation; + +# ifdef __cplusplus +} +# endif + +#endif + +#endif diff --git a/src/3rdparty/sodium/randombytes_salsa20_random.h b/src/3rdparty/sodium/randombytes_salsa20_random.h new file mode 100644 index 0000000..4deae15 --- /dev/null +++ b/src/3rdparty/sodium/randombytes_salsa20_random.h @@ -0,0 +1,19 @@ + +#ifndef randombytes_salsa20_random_H +#define randombytes_salsa20_random_H + +#include "export.h" +#include "randombytes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +SODIUM_EXPORT +extern struct randombytes_implementation randombytes_salsa20_implementation; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/randombytes_sysrandom.h b/src/3rdparty/sodium/randombytes_sysrandom.h new file mode 100644 index 0000000..9e27b67 --- /dev/null +++ b/src/3rdparty/sodium/randombytes_sysrandom.h @@ -0,0 +1,19 @@ + +#ifndef randombytes_sysrandom_H +#define randombytes_sysrandom_H + +#include "export.h" +#include "randombytes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +SODIUM_EXPORT +extern struct randombytes_implementation randombytes_sysrandom_implementation; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/runtime.h b/src/3rdparty/sodium/runtime.h new file mode 100644 index 0000000..7f15d58 --- /dev/null +++ b/src/3rdparty/sodium/runtime.h @@ -0,0 +1,52 @@ + +#ifndef sodium_runtime_H +#define sodium_runtime_H + +#include "export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +SODIUM_EXPORT_WEAK +int sodium_runtime_has_neon(void); + +SODIUM_EXPORT_WEAK +int sodium_runtime_has_sse2(void); + +SODIUM_EXPORT_WEAK +int sodium_runtime_has_sse3(void); + +SODIUM_EXPORT_WEAK +int sodium_runtime_has_ssse3(void); + +SODIUM_EXPORT_WEAK +int sodium_runtime_has_sse41(void); + +SODIUM_EXPORT_WEAK +int sodium_runtime_has_avx(void); + +SODIUM_EXPORT_WEAK +int sodium_runtime_has_avx2(void); + +SODIUM_EXPORT_WEAK +int sodium_runtime_has_avx512f(void); + +SODIUM_EXPORT_WEAK +int sodium_runtime_has_pclmul(void); + +SODIUM_EXPORT_WEAK +int sodium_runtime_has_aesni(void); + +SODIUM_EXPORT_WEAK +int sodium_runtime_has_rdrand(void); + +/* ------------------------------------------------------------------------- */ + +int _sodium_runtime_get_cpu_features(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/utils.h b/src/3rdparty/sodium/utils.h new file mode 100644 index 0000000..46eb331 --- /dev/null +++ b/src/3rdparty/sodium/utils.h @@ -0,0 +1,170 @@ + +#ifndef sodium_utils_H +#define sodium_utils_H + +#include + +#include "export.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef SODIUM_C99 +# if defined(__cplusplus) || !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L +# define SODIUM_C99(X) +# else +# define SODIUM_C99(X) X +# endif +#endif + +SODIUM_EXPORT +void sodium_memzero(void * const pnt, const size_t len); + +SODIUM_EXPORT +void sodium_stackzero(const size_t len); + +/* + * WARNING: sodium_memcmp() must be used to verify if two secret keys + * are equal, in constant time. + * It returns 0 if the keys are equal, and -1 if they differ. + * This function is not designed for lexicographical comparisons. + */ +SODIUM_EXPORT +int sodium_memcmp(const void * const b1_, const void * const b2_, size_t len) + __attribute__ ((warn_unused_result)); + +/* + * sodium_compare() returns -1 if b1_ < b2_, 1 if b1_ > b2_ and 0 if b1_ == b2_ + * It is suitable for lexicographical comparisons, or to compare nonces + * and counters stored in little-endian format. + * However, it is slower than sodium_memcmp(). + */ +SODIUM_EXPORT +int sodium_compare(const unsigned char *b1_, const unsigned char *b2_, + size_t len) + __attribute__ ((warn_unused_result)); + +SODIUM_EXPORT +int sodium_is_zero(const unsigned char *n, const size_t nlen); + +SODIUM_EXPORT +void sodium_increment(unsigned char *n, const size_t nlen); + +SODIUM_EXPORT +void sodium_add(unsigned char *a, const unsigned char *b, const size_t len); + +SODIUM_EXPORT +char *sodium_bin2hex(char * const hex, const size_t hex_maxlen, + const unsigned char * const bin, const size_t bin_len); + +SODIUM_EXPORT +int sodium_hex2bin(unsigned char * const bin, const size_t bin_maxlen, + const char * const hex, const size_t hex_len, + const char * const ignore, size_t * const bin_len, + const char ** const hex_end); + +#define sodium_base64_VARIANT_ORIGINAL 1 +#define sodium_base64_VARIANT_ORIGINAL_NO_PADDING 3 +#define sodium_base64_VARIANT_URLSAFE 5 +#define sodium_base64_VARIANT_URLSAFE_NO_PADDING 7 + +/* + * Computes the required length to encode BIN_LEN bytes as a base64 string + * using the given variant. The computed length includes a trailing \0. + */ +#define sodium_base64_ENCODED_LEN(BIN_LEN, VARIANT) \ + (((BIN_LEN) / 3U) * 4U + \ + ((((BIN_LEN) - ((BIN_LEN) / 3U) * 3U) | (((BIN_LEN) - ((BIN_LEN) / 3U) * 3U) >> 1)) & 1U) * \ + (4U - (~((((VARIANT) & 2U) >> 1) - 1U) & (3U - ((BIN_LEN) - ((BIN_LEN) / 3U) * 3U)))) + 1U) + +SODIUM_EXPORT +size_t sodium_base64_encoded_len(const size_t bin_len, const int variant); + +SODIUM_EXPORT +char *sodium_bin2base64(char * const b64, const size_t b64_maxlen, + const unsigned char * const bin, const size_t bin_len, + const int variant); + +SODIUM_EXPORT +int sodium_base642bin(unsigned char * const bin, const size_t bin_maxlen, + const char * const b64, const size_t b64_len, + const char * const ignore, size_t * const bin_len, + const char ** const b64_end, const int variant); + +SODIUM_EXPORT +int sodium_mlock(void * const addr, const size_t len); + +SODIUM_EXPORT +int sodium_munlock(void * const addr, const size_t len); + +/* WARNING: sodium_malloc() and sodium_allocarray() are not general-purpose + * allocation functions. + * + * They return a pointer to a region filled with 0xd0 bytes, immediately + * followed by a guard page. + * As a result, accessing a single byte after the requested allocation size + * will intentionally trigger a segmentation fault. + * + * A canary and an additional guard page placed before the beginning of the + * region may also kill the process if a buffer underflow is detected. + * + * The memory layout is: + * [unprotected region size (read only)][guard page (no access)][unprotected pages (read/write)][guard page (no access)] + * With the layout of the unprotected pages being: + * [optional padding][16-bytes canary][user region] + * + * However: + * - These functions are significantly slower than standard functions + * - Each allocation requires 3 or 4 additional pages + * - The returned address will not be aligned if the allocation size is not + * a multiple of the required alignment. For this reason, these functions + * are designed to store data, such as secret keys and messages. + * + * sodium_malloc() can be used to allocate any libsodium data structure. + * + * The crypto_generichash_state structure is packed and its length is + * either 357 or 361 bytes. For this reason, when using sodium_malloc() to + * allocate a crypto_generichash_state structure, padding must be added in + * order to ensure proper alignment. crypto_generichash_statebytes() + * returns the rounded up structure size, and should be prefered to sizeof(): + * state = sodium_malloc(crypto_generichash_statebytes()); + */ + +SODIUM_EXPORT +void *sodium_malloc(const size_t size) + __attribute__ ((malloc)); + +SODIUM_EXPORT +void *sodium_allocarray(size_t count, size_t size) + __attribute__ ((malloc)); + +SODIUM_EXPORT +void sodium_free(void *ptr); + +SODIUM_EXPORT +int sodium_mprotect_noaccess(void *ptr); + +SODIUM_EXPORT +int sodium_mprotect_readonly(void *ptr); + +SODIUM_EXPORT +int sodium_mprotect_readwrite(void *ptr); + +SODIUM_EXPORT +int sodium_pad(size_t *padded_buflen_p, unsigned char *buf, + size_t unpadded_buflen, size_t blocksize, size_t max_buflen); + +SODIUM_EXPORT +int sodium_unpad(size_t *unpadded_buflen_p, const unsigned char *buf, + size_t padded_buflen, size_t blocksize); + +/* -------- */ + +int _sodium_alloc_init(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/version.h b/src/3rdparty/sodium/version.h new file mode 100644 index 0000000..e6af10b --- /dev/null +++ b/src/3rdparty/sodium/version.h @@ -0,0 +1,33 @@ + +#ifndef sodium_version_H +#define sodium_version_H + +#include "export.h" + +#define SODIUM_VERSION_STRING "1.0.16" + +#define SODIUM_LIBRARY_VERSION_MAJOR 10 +#define SODIUM_LIBRARY_VERSION_MINOR 1 + + +#ifdef __cplusplus +extern "C" { +#endif + +SODIUM_EXPORT +const char *sodium_version_string(void); + +SODIUM_EXPORT +int sodium_library_version_major(void); + +SODIUM_EXPORT +int sodium_library_version_minor(void); + +SODIUM_EXPORT +int sodium_library_minimal(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/3rdparty/sodium/version.h.in b/src/3rdparty/sodium/version.h.in new file mode 100644 index 0000000..8a72044 --- /dev/null +++ b/src/3rdparty/sodium/version.h.in @@ -0,0 +1,33 @@ + +#ifndef sodium_version_H +#define sodium_version_H + +#include "export.h" + +#define SODIUM_VERSION_STRING "@VERSION@" + +#define SODIUM_LIBRARY_VERSION_MAJOR @SODIUM_LIBRARY_VERSION_MAJOR@ +#define SODIUM_LIBRARY_VERSION_MINOR @SODIUM_LIBRARY_VERSION_MINOR@ +@SODIUM_LIBRARY_MINIMAL_DEF@ + +#ifdef __cplusplus +extern "C" { +#endif + +SODIUM_EXPORT +const char *sodium_version_string(void); + +SODIUM_EXPORT +int sodium_library_version_major(void); + +SODIUM_EXPORT +int sodium_library_version_minor(void); + +SODIUM_EXPORT +int sodium_library_minimal(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/addressbook.cpp b/src/addressbook.cpp index 7d74cbd..82d99a5 100644 --- a/src/addressbook.cpp +++ b/src/addressbook.cpp @@ -3,6 +3,7 @@ #include "ui_mainwindow.h" #include "settings.h" #include "mainwindow.h" +#include "rpc.h" AddressBookModel::AddressBookModel(QTableView *parent) @@ -110,7 +111,7 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target) { } // Connect the dialog's closing to updating the label address completor - QObject::connect(&d, &QDialog::finished, [=] (auto) { parent->updateLabelsAutoComplete(); }); + QObject::connect(&d, &QDialog::finished, [=] (auto) { parent->updateLabels(); }); // If there is a target then make it the addr for the "Add to" button if (target != nullptr && Settings::isValidAddress(target->text())) { @@ -221,6 +222,9 @@ void AddressBook::open(MainWindow* parent, QLineEdit* target) { fnSetTargetLabelAddr(target, item.first, item.second); } }; + + // Refresh after the dialog is closed to update the labels everywhere. + parent->getRPC()->refresh(true); } //============= @@ -254,9 +258,6 @@ void AddressBook::readFromStorage() { } void AddressBook::writeToStorage() { - if (allLabels.isEmpty()) - return; - QFile file(AddressBook::writeableFile()); file.open(QIODevice::ReadWrite | QIODevice::Truncate); QDataStream out(&file); // we will serialize the data into the file diff --git a/src/balancestablemodel.cpp b/src/balancestablemodel.cpp index da344ee..28261d2 100644 --- a/src/balancestablemodel.cpp +++ b/src/balancestablemodel.cpp @@ -23,7 +23,8 @@ void BalancesTableModel::setNewData(const QMap* balances, delete modeldata; modeldata = new QList>(); std::for_each(balances->keyBegin(), balances->keyEnd(), [=] (auto keyIt) { - modeldata->push_back(std::make_tuple(keyIt, balances->value(keyIt))); + if (balances->value(keyIt) > 0) + modeldata->push_back(std::make_tuple(keyIt, balances->value(keyIt))); }); // And then update the data diff --git a/src/connection.cpp b/src/connection.cpp index 5db52a3..444b6e9 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -2,6 +2,7 @@ #include "mainwindow.h" #include "settings.h" #include "ui_connection.h" +#include "ui_createzcashconfdialog.h" #include "rpc.h" #include "precompiled.h" @@ -26,7 +27,8 @@ ConnectionLoader::~ConnectionLoader() { void ConnectionLoader::loadConnection() { QTimer::singleShot(1, [=]() { this->doAutoConnect(); }); - d->exec(); + if (!Settings::getInstance()->isHeadless()) + d->exec(); } void ConnectionLoader::doAutoConnect(bool tryEzcashdStart) { @@ -128,9 +130,47 @@ void ConnectionLoader::createZcashConf() { main->logger->write("createZcashConf"); auto confLocation = zcashConfWritableLocation(); - main->logger->write("Creating file " + confLocation); - QFileInfo fi(confLocation); + + QDialog d(main); + Ui_createZcashConf ui; + ui.setupUi(&d); + + QPixmap logo(":/img/res/zcashdlogo.gif"); + ui.lblTopIcon->setBasePixmap(logo.scaled(256, 256, Qt::KeepAspectRatio, Qt::SmoothTransformation)); + ui.btnPickDir->setEnabled(false); + + ui.grpAdvanced->setVisible(false); + QObject::connect(ui.btnAdvancedConfig, &QPushButton::toggled, [=](bool isVisible) { + ui.grpAdvanced->setVisible(isVisible); + ui.btnAdvancedConfig->setText(isVisible ? QObject::tr("Hide Advanced Config") : QObject::tr("Show Advanced Config")); + }); + + QObject::connect(ui.chkCustomDatadir, &QCheckBox::stateChanged, [=](int chked) { + if (chked == Qt::Checked) { + ui.btnPickDir->setEnabled(true); + } + else { + ui.btnPickDir->setEnabled(false); + } + }); + + QObject::connect(ui.btnPickDir, &QPushButton::clicked, [=]() { + auto datadir = QFileDialog::getExistingDirectory(main, QObject::tr("Choose data directory"), ui.lblDirName->text(), QFileDialog::ShowDirsOnly); + if (!datadir.isEmpty()) { + ui.lblDirName->setText(QDir::toNativeSeparators(datadir)); + } + }); + + // Show the dialog + QString datadir = ""; + bool useTor = false; + if (d.exec() == QDialog::Accepted) { + datadir = ui.lblDirName->text(); + useTor = ui.chkUseTor->isChecked(); + } + + main->logger->write("Creating file " + confLocation); QDir().mkdir(fi.dir().absolutePath()); QFile file(confLocation); @@ -145,6 +185,13 @@ void ConnectionLoader::createZcashConf() { out << "addnode=mainnet.z.cash\n"; out << "rpcuser=zec-qt-wallet\n"; out << "rpcpassword=" % randomPassword() << "\n"; + if (!datadir.isEmpty()) { + out << "datadir=" % datadir % "\n"; + } + if (useTor) { + out << "proxy=127.0.0.1:9050\n"; + } + file.close(); // Now that zcash.conf exists, try to autoconnect again @@ -396,6 +443,7 @@ void ConnectionLoader::refreshZcashdState(Connection* connection, std::function< [=] (auto) { // Success, hide the dialog if it was shown. d->hide(); + main->logger->write("zcashd is online."); this->doRPCSetConnection(connection); }, [=] (auto reply, auto res) { @@ -435,6 +483,8 @@ void ConnectionLoader::refreshZcashdState(Connection* connection, std::function< void ConnectionLoader::showInformation(QString info, QString detail) { connD->status->setText(info); connD->statusDetail->setText(detail); + + main->logger->write(info + ":" + detail); } /** diff --git a/src/createzcashconfdialog.ui b/src/createzcashconfdialog.ui new file mode 100644 index 0000000..a8c5d50 --- /dev/null +++ b/src/createzcashconfdialog.ui @@ -0,0 +1,212 @@ + + + createZcashConf + + + + 0 + 0 + 508 + 352 + + + + Configure zcash.conf + + + + + + + 0 + 0 + + + + background: #fff; + + + + + + true + + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + true + + + + + + + + + Show Advanced Configuration + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Your zcash node will be configured for you automatically + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + + + + Use custom datadir + + + + + + + Please choose a directory to store your wallet.dat and blockchain + + + + + + + + + Choose directory + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + Connect over Tor + + + + + + + Please note that you'll need to already have a Tor service configured on port 9050 + + + + + + + + + + + FilledIconLabel + QLabel +
fillediconlabel.h
+
+
+ + + + buttonBox + accepted() + createZcashConf + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + createZcashConf + reject() + + + 316 + 260 + + + 286 + 274 + + + + +
diff --git a/src/logger.cpp b/src/logger.cpp index 45751f1..589b877 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -2,11 +2,13 @@ Logger::Logger(QObject *parent, QString fileName) : QObject(parent) { m_showDate = true; + if (!fileName.isEmpty()) { file = new QFile; file->setFileName(fileName); file->open(QIODevice::Append | QIODevice::Text); } + write("=========Startup=========="); } @@ -14,7 +16,7 @@ void Logger::write(const QString &value) { if (!file) return; - QString text = value;// + ""; + QString text = value; text = QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss ") + text; QTextStream out(file); out.setCodec("UTF-8"); diff --git a/src/main.cpp b/src/main.cpp index 77cca9a..a9827b7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,55 +1,271 @@ #include "mainwindow.h" +#include "rpc.h" #include "settings.h" #include "turnstile.h" #include "version.h" -int main(int argc, char *argv[]) +class SignalHandler { - QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); - QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); +public: + SignalHandler(int mask = DEFAULT_SIGNALS); + virtual ~SignalHandler(); - QApplication a(argc, argv); + enum SIGNALS + { + SIG_UNHANDLED = 0, // Physical signal not supported by this class + SIG_NOOP = 1, // The application is requested to do a no-op (only a target that platform-specific signals map to when they can't be raised anyway) + SIG_INT = 2, // Control+C (should terminate but consider that it's a normal way to do so; can delay a bit) + SIG_TERM = 4, // Control+Break (should terminate now without regarding the consquences) + SIG_CLOSE = 8, // Container window closed (should perform normal termination, like Ctrl^C) [Windows only; on Linux it maps to SIG_TERM] + SIG_RELOAD = 16, // Reload the configuration [Linux only, physical signal is SIGHUP; on Windows it maps to SIG_NOOP] + DEFAULT_SIGNALS = SIG_INT | SIG_TERM | SIG_CLOSE, + }; + static const int numSignals = 6; - QCoreApplication::setOrganizationName("zec-qt-wallet-org"); - QCoreApplication::setApplicationName("zec-qt-wallet"); + virtual bool handleSignal(int signal) = 0; - QString locale = QLocale::system().name(); - locale.truncate(locale.lastIndexOf('_')); // Get the language code - qDebug() << "Loading locale " << locale; - - QTranslator translator; - translator.load(QString(":/translations/res/zec_qt_wallet_") + locale); - a.installTranslator(&translator); +private: + int _mask; +}; - QIcon icon(":/icons/res/icon.ico"); - QApplication::setWindowIcon(icon); +#include - #ifdef Q_OS_LINUX - QFontDatabase::addApplicationFont(":/fonts/res/Ubuntu-R.ttf"); - qApp->setFont(QFont("Ubuntu", 11, QFont::Normal, false)); - #endif +#ifndef _WIN32 + +#include - // QRandomGenerator generates a secure random number, which we use to seed. -#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) - unsigned int seed = QRandomGenerator::securelySeeded().generate(); #else - // This will be used only during debugging for compatibility reasons - unsigned int seed = std::time(0); -#endif - std::srand(seed); - Settings::init(); +#endif //!_WIN32 + +// There can be only ONE SignalHandler per process +SignalHandler* g_handler(NULL); + +#ifdef _WIN32 - if (argc >= 2 && QString::fromStdString(argv[1]) == "--no-embedded") { - Settings::getInstance()->setUseEmbedded(false); - } else { - Settings::getInstance()->setUseEmbedded(true); +#else //_WIN32 + +void POSIX_handleFunc(int); +int POSIX_physicalToLogical(int); +int POSIX_logicalToPhysical(int); + +#endif //_WIN32 + +SignalHandler::SignalHandler(int mask) : _mask(mask) +{ + assert(g_handler == NULL); + g_handler = this; + +#ifdef _WIN32 + +#endif //_WIN32 + + for (int i=0;ihandleSignal(signo); + } +} +#endif //_WIN32 + +class Application : public SignalHandler +{ +public: + Application() : SignalHandler(SignalHandler::SIG_INT), w(nullptr) {} + + ~Application() { delete w; } + + int main(int argc, char *argv[]) { + QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); + QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + + QApplication a(argc, argv); + + QCoreApplication::setOrganizationName("zec-qt-wallet-org"); + QCoreApplication::setApplicationName("zec-qt-wallet"); + + QString locale = QLocale::system().name(); + locale.truncate(locale.lastIndexOf('_')); // Get the language code + qDebug() << "Loading locale " << locale; + + QTranslator translator; + translator.load(QString(":/translations/res/zec_qt_wallet_") + locale); + a.installTranslator(&translator); + + QIcon icon(":/icons/res/icon.ico"); + QApplication::setWindowIcon(icon); + + #ifdef Q_OS_LINUX + QFontDatabase::addApplicationFont(":/fonts/res/Ubuntu-R.ttf"); + qApp->setFont(QFont("Ubuntu", 11, QFont::Normal, false)); + #endif + + // QRandomGenerator generates a secure random number, which we use to seed. + #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) + unsigned int seed = QRandomGenerator::securelySeeded().generate(); + #else + // This will be used only during debugging for compatibility reasons + unsigned int seed = std::time(0); + #endif + std::srand(seed); + + Settings::init(); + + // Set up libsodium + if (sodium_init() < 0) { + /* panic! the library couldn't be initialized, it is not safe to use */ + qDebug() << "libsodium is not initialized!"; + exit(0); + } + + // Command line parser + QCommandLineParser parser; + parser.setApplicationDescription("Shielded desktop wallet and embedded full node for Zcash"); + parser.addHelpOption(); + + // A boolean option for running it headless + QCommandLineOption headlessOption(QStringList() << "headless", "Running it via GUI."); + parser.addOption(headlessOption); + + QCommandLineOption noembeddedOption(QStringList() << "no-embedded", "Disable embedded zcashd"); + parser.addOption(noembeddedOption); + + parser.process(a); + if (parser.isSet(noembeddedOption)) { + Settings::getInstance()->setUseEmbedded(false); + } else { + Settings::getInstance()->setUseEmbedded(true); + } + + w = new MainWindow(); + w->setWindowTitle("zec-qt-wallet v" + QString(APP_VERSION)); + + if (parser.isSet(headlessOption)) { + Settings::getInstance()->setHeadless(true); + a.setQuitOnLastWindowClosed(false); + } else { + Settings::getInstance()->setHeadless(false); + w->show(); + } + + return QApplication::exec(); + } + + void DispatchToMainThread(std::function callback) + { + // any thread + QTimer* timer = new QTimer(); + timer->moveToThread(qApp->thread()); + timer->setSingleShot(true); + QObject::connect(timer, &QTimer::timeout, [=]() + { + // main thread + callback(); + timer->deleteLater(); + }); + QMetaObject::invokeMethod(timer, "start", Qt::QueuedConnection, Q_ARG(int, 0)); + } + + bool handleSignal(int signal) + { + std::cout << std::endl << "Interrupted with signal " << signal << std::endl; + + if (w && w->getRPC()) { + // Blocking call to closeEvent on the UI thread. + DispatchToMainThread([=] { + w->doClose(); + QApplication::quit(); + }); + } else { + QApplication::quit(); + } + + return true; + } + +private: + MainWindow* w; +}; + +int main(int argc, char* argv[]) +{ + Application app; + return app.main(argc, argv); +} + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c09a184..34e8b28 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1,6 +1,7 @@ #include "mainwindow.h" #include "addressbook.h" #include "ui_mainwindow.h" +#include "ui_mobileappconnector.h" #include "ui_addressbook.h" #include "ui_zboard.h" #include "ui_privkey.h" @@ -15,6 +16,7 @@ #include "turnstile.h" #include "senttxstore.h" #include "connection.h" +#include "websockets.h" using json = nlohmann::json; @@ -43,7 +45,7 @@ MainWindow::MainWindow(QWidget *parent) : rpc->checkForUpdate(false); }); - // Pay zcash URI + // Pay Zcash URI QObject::connect(ui->actionPay_URI, &QAction::triggered, this, &MainWindow::payZcashURI); // Import Private Key @@ -61,6 +63,14 @@ MainWindow::MainWindow(QWidget *parent) : // z-Board.net QObject::connect(ui->actionz_board_net, &QAction::triggered, this, &MainWindow::postToZBoard); + // Connect mobile app + QObject::connect(ui->actionConnect_Mobile_App, &QAction::triggered, this, [=] () { + if (rpc->getConnection() == nullptr) + return; + + AppDataServer::getInstance()->connectAppDialog(this); + }); + // Address Book QObject::connect(ui->action_Address_Book, &QAction::triggered, this, &MainWindow::addressBook); @@ -94,8 +104,47 @@ MainWindow::MainWindow(QWidget *parent) : rpc = new RPC(this); restoreSavedStates(); + + if (AppDataServer::getInstance()->isAppConnected()) { + auto ads = AppDataServer::getInstance(); + + QString wormholecode = ""; + if (ads->getAllowInternetConnection()) + wormholecode = ads->getWormholeCode(ads->getSecretHex()); + + createWebsocket(wormholecode); + } } +void MainWindow::createWebsocket(QString wormholecode) { + qDebug() << "Listening for app connections on port 8237"; + // Create the websocket server, for listening to direct connections + wsserver = new WSServer(8237, false, this); + + if (!wormholecode.isEmpty()) { + // Connect to the wormhole service + wormhole = new WormholeClient(this, wormholecode); + } +} + +void MainWindow::stopWebsocket() { + delete wsserver; + wsserver = nullptr; + + delete wormhole; + wormhole = nullptr; + + qDebug() << "Websockets for app connections shut down"; +} + +bool MainWindow::isWebsocketListening() { + return wsserver != nullptr; +} + +void MainWindow::replaceWormholeClient(WormholeClient* newClient) { + delete wormhole; + wormhole = newClient; +} void MainWindow::restoreSavedStates() { QSettings s; @@ -105,6 +154,10 @@ void MainWindow::restoreSavedStates() { ui->transactionsTable->horizontalHeader()->restoreState(s.value("tratablegeometry").toByteArray()); } +void MainWindow::doClose() { + closeEvent(nullptr); +} + void MainWindow::closeEvent(QCloseEvent* event) { QSettings s; @@ -112,11 +165,14 @@ void MainWindow::closeEvent(QCloseEvent* event) { s.setValue("baltablegeometry", ui->balancesTable->horizontalHeader()->saveState()); s.setValue("tratablegeometry", ui->transactionsTable->horizontalHeader()->saveState()); + s.sync(); + // Let the RPC know to shut down any running service. rpc->shutdownZcashd(); // Bubble up - QMainWindow::closeEvent(event); + if (event) + QMainWindow::closeEvent(event); } void MainWindow::turnstileProgress() { @@ -239,12 +295,18 @@ void MainWindow::turnstileDoMigration(QString fromAddr) { auto fnUpdateSproutBalance = [=] (QString addr) { double bal = 0; + + // The currentText contains the balance as well, so strip that. + if (addr.contains("(")) { + addr = addr.left(addr.indexOf("(")); + } + if (addr.startsWith("All")) { bal = fnGetAllSproutBalance(); } else { bal = rpc->getAllBalances()->value(addr); } - + auto balTxt = Settings::getZECUSDDisplayFormat(bal); if (bal < Turnstile::minMigrationAmount) { @@ -518,6 +580,7 @@ void MainWindow::donate() { ui->tabWidget->setCurrentIndex(1); } + void MainWindow::postToZBoard() { QDialog d(this); Ui_zboard zb; @@ -620,7 +683,7 @@ void MainWindow::postToZBoard() { rpc->executeTransaction(tx, [=] (QString opid) { ui->statusBar->showMessage(tr("Computing Tx: ") % opid); }, - [=] (QString opid, QString txid) { + [=] (QString /*opid*/, QString txid) { ui->statusBar->showMessage(Settings::txidStatusMessage + " " + txid); }, [=] (QString opid, QString errStr) { @@ -642,10 +705,6 @@ void MainWindow::doImport(QList* keys) { if (keys->isEmpty()) { delete keys; - - QMessageBox::information(this, - "Imported", tr("The keys were imported. It may take several minutes to rescan the blockchain. Until then, functionality may be limited"), - QMessageBox::Ok); ui->statusBar->showMessage(tr("Private key import rescan finished")); return; } @@ -716,7 +775,7 @@ void MainWindow::payZcashURI() { if (kv[0].toLower() == "amt" || kv[0].toLower() == "amount") { amount = kv[1].toDouble(); - } else if (kv[0].toLower() == "memo") { + } else if (kv[0].toLower() == "memo" || kv[0].toLower() == "message" || kv[0].toLower() == "msg") { memo = kv[1]; // Test if this is hex @@ -778,7 +837,12 @@ void MainWindow::importPrivKey() { }); // Start the import. The function takes ownership of keys - doImport(keys); + QTimer::singleShot(1, [=]() {doImport(keys);}); + + // Show the dialog that keys will be imported. + QMessageBox::information(this, + "Imported", tr("The keys were imported. It may take several minutes to rescan the blockchain. Until then, functionality may be limited"), + QMessageBox::Ok); } } @@ -814,7 +878,7 @@ void MainWindow::backupWalletDat() { if (Settings::getInstance()->isTestnet()) { zcashdir.cd("testnet3"); - backupDefaultName = "tesetnet-" + backupDefaultName; + backupDefaultName = "testnet-" + backupDefaultName; } QFile wallet(zcashdir.filePath("wallet.dat")); @@ -1020,12 +1084,15 @@ void MainWindow::setupTransactionsTab() { QString memo = txModel->getMemo(index.row()); if (!memo.isEmpty()) { - QMessageBox::information(this, tr("Memo"), memo, QMessageBox::Ok); + QMessageBox mb(QMessageBox::Information, tr("Memo"), memo, QMessageBox::Ok, this); + mb.setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); + mb.exec(); } }); // Set up context menu on transactions tab ui->transactionsTable->setContextMenuPolicy(Qt::CustomContextMenu); + // Table right click QObject::connect(ui->transactionsTable, &QTableView::customContextMenuRequested, [=] (QPoint pos) { QModelIndex index = ui->transactionsTable->indexAt(pos); @@ -1063,11 +1130,13 @@ void MainWindow::setupTransactionsTab() { if (!memo.isEmpty()) { menu.addAction(tr("View Memo"), [=] () { - QMessageBox::information(this, tr("Memo"), memo, QMessageBox::Ok); + QMessageBox mb(QMessageBox::Information, tr("Memo"), memo, QMessageBox::Ok, this); + mb.setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); + mb.exec(); }); } - // If memo contains a reply to addess, add a "Reply to" menu item + // If memo contains a reply to address, add a "Reply to" menu item if (!memo.isEmpty()) { int lastPost = memo.trimmed().lastIndexOf(QRegExp("[\r\n]+")); QString lastWord = memo.right(memo.length() - lastPost - 1); @@ -1159,33 +1228,27 @@ void MainWindow::setupRecieveTab() { }); }; - auto fnUpdateTAddrCombo = [=] (bool checked) { - if (checked) { - auto utxos = this->rpc->getUTXOs(); - ui->listRecieveAddresses->clear(); - - std::for_each(utxos->begin(), utxos->end(), [=](auto& utxo) { - auto addr = utxo.address; - if (addr.startsWith("t") && ui->listRecieveAddresses->findText(addr) < 0) { - auto bal = rpc->getAllBalances()->value(addr); - ui->listRecieveAddresses->addItem(addr, bal); - } - }); - } - }; - // Connect t-addr radio button QObject::connect(ui->rdioTAddr, &QRadioButton::toggled, [=] (bool checked) { // Whenever the t-address is selected, we generate a new address, because we don't // want to reuse t-addrs if (checked && this->rpc->getUTXOs() != nullptr) { - fnUpdateTAddrCombo(checked); + updateTAddrCombo(checked); addNewTAddr(); } }); // zAddr toggle button, one for sprout and one for sapling - QObject::connect(ui->rdioZAddr, &QRadioButton::toggled, addZAddrsToComboList(false)); + QObject::connect(ui->rdioZAddr, &QRadioButton::toggled, [=](bool checked) { + ui->btnRecieveNewAddr->setEnabled(!checked); + if (checked) { + ui->btnRecieveNewAddr->setToolTip(tr("Creation of new Sprout addresses is deprecated")); + } + else { + ui->btnRecieveNewAddr->setToolTip(""); + } + addZAddrsToComboList(false)(checked); + }); QObject::connect(ui->rdioZSAddr, &QRadioButton::toggled, addZAddrsToComboList(true)); // Explicitly get new address button. @@ -1218,7 +1281,7 @@ void MainWindow::setupRecieveTab() { if (Settings::getInstance()->isSaplingActive()) { ui->rdioZSAddr->setVisible(true); ui->rdioZSAddr->setChecked(true); - ui->rdioZAddr->setText("z-Addr(Sprout)"); + ui->rdioZAddr->setText("z-Addr(Legacy Sprout)"); } else { ui->rdioZSAddr->setVisible(false); ui->rdioZAddr->setChecked(true); @@ -1245,7 +1308,6 @@ void MainWindow::setupRecieveTab() { ui->rcvBal->clear(); ui->txtRecieve->clear(); ui->qrcodeDisplay->clear(); - ui->lblUsed->clear(); return; } @@ -1260,16 +1322,16 @@ void MainWindow::setupRecieveTab() { ui->rcvLabel->setText(label); ui->rcvBal->setText(Settings::getZECUSDDisplayFormat(rpc->getAllBalances()->value(addr))); ui->txtRecieve->setPlainText(addr); - ui->qrcodeDisplay->setAddress(addr); + ui->qrcodeDisplay->setQrcodeString(addr); if (rpc->getUsedAddresses()->value(addr, false)) { - ui->lblUsed->setText(tr("Address has been previously used")); + ui->rcvBal->setToolTip(tr("Address has been previously used")); } else { - ui->lblUsed->setText(tr("Address is unused")); + ui->rcvBal->setToolTip(tr("Address is unused")); } }); - // Recieve tab add/update label + // Receive tab add/update label QObject::connect(ui->rcvUpdateLabel, &QPushButton::clicked, [=]() { QString addr = ui->listRecieveAddresses->currentText(); if (addr.isEmpty()) @@ -1296,13 +1358,8 @@ void MainWindow::setupRecieveTab() { AddressBook::getInstance()->addAddressLabel(label, addr); } - // Update the UI - if (ui->rdioTAddr->isChecked()) { - fnUpdateTAddrCombo(true); - } - else { - addZAddrsToComboList(ui->rdioZSAddr->isChecked())(true); - } + // Update labels everywhere on the UI + updateLabels(); // Show the user feedback if (!info.isEmpty()) { @@ -1320,6 +1377,38 @@ void MainWindow::setupRecieveTab() { }); } +void MainWindow::updateTAddrCombo(bool checked) { + if (checked) { + auto utxos = this->rpc->getUTXOs(); + ui->listRecieveAddresses->clear(); + + std::for_each(utxos->begin(), utxos->end(), [=](auto& utxo) { + auto addr = utxo.address; + if (addr.startsWith("t") && ui->listRecieveAddresses->findText(addr) < 0) { + auto bal = rpc->getAllBalances()->value(addr); + ui->listRecieveAddresses->addItem(addr, bal); + } + }); + } +}; + +// Updates the labels everywhere on the UI. Call this after the labels have been updated +void MainWindow::updateLabels() { + // Update the Receive tab + if (ui->rdioTAddr->isChecked()) { + updateTAddrCombo(true); + } + else { + addZAddrsToComboList(ui->rdioZSAddr->isChecked())(true); + } + + // Update the Send Tab + updateFromCombo(); + + // Update the autocomplete + updateLabelsAutoComplete(); +} + MainWindow::~MainWindow() { delete ui; @@ -1330,4 +1419,7 @@ MainWindow::~MainWindow() delete loadingMovie; delete logger; + + delete wsserver; + delete wormhole; } diff --git a/src/mainwindow.h b/src/mainwindow.h index f177dba..0b7679f 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -9,6 +9,8 @@ // Forward declare to break circular dependency. class RPC; class Settings; +class WSServer; +class WormholeClient; using json = nlohmann::json; @@ -42,8 +44,18 @@ public: void updateLabelsAutoComplete(); RPC* getRPC() { return rpc; } + QString doSendTxValidations(Tx tx); void setDefaultPayFrom(); + void replaceWormholeClient(WormholeClient* newClient); + bool isWebsocketListening(); + void createWebsocket(QString wormholecode); + void stopWebsocket(); + + void updateLabels(); + void updateTAddrCombo(bool checked); + void updateFromCombo(); + Ui::MainWindow* ui; QLabel* statusLabel; @@ -52,6 +64,9 @@ public: QWidget* zcashdtab; Logger* logger; + + void doClose(); + private: void closeEvent(QCloseEvent* event); @@ -89,9 +104,7 @@ private: void memoButtonClicked(int number, bool includeReplyTo = false); void setMemoEnabled(int number, bool enabled); - - QString doSendTxValidations(Tx tx); - + void donate(); void addressBook(); void payZcashURI(); @@ -106,6 +119,9 @@ private: void restoreSavedStates(); + WSServer* wsserver = nullptr; + WormholeClient* wormhole = nullptr; + RPC* rpc = nullptr; QCompleter* labelCompleter = nullptr; diff --git a/src/mainwindow.ui b/src/mainwindow.ui index e86c960..72647a6 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -531,7 +531,7 @@ - + @@ -680,7 +680,7 @@ - z-Addr(Sapling) + z-Addr @@ -700,7 +700,7 @@ - z-Addr(Sprout) + z-Addr(Legacy Sprout) @@ -790,17 +790,7 @@ - - - - Address - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - + @@ -824,17 +814,13 @@ - - + + - Address used + Address - - - - - - + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop @@ -1043,7 +1029,7 @@ 0 0 968 - 22 + 19 @@ -1072,8 +1058,10 @@ &Apps - + + + @@ -1165,6 +1153,14 @@ Pay zcash &URI... + + + Connect mobile &app + + + Ctrl+M + + @@ -1173,16 +1169,16 @@ QLabel
qrcodelabel.h
- - FilledIconLabel - QLabel -
fillediconlabel.h
-
AddressCombo QComboBox
addresscombo.h
+ + FilledIconLabel + QLabel +
fillediconlabel.h
+
tabWidget diff --git a/src/mobileappconnector.cpp b/src/mobileappconnector.cpp new file mode 100644 index 0000000..67f4486 --- /dev/null +++ b/src/mobileappconnector.cpp @@ -0,0 +1,14 @@ +#include "mobileappconnector.h" +#include "ui_mobileappconnector.h" + +MobileAppConnector::MobileAppConnector(QWidget *parent) : + QDialog(parent), + ui(new Ui::MobileAppConnector) +{ + ui->setupUi(this); +} + +MobileAppConnector::~MobileAppConnector() +{ + delete ui; +} diff --git a/src/mobileappconnector.h b/src/mobileappconnector.h new file mode 100644 index 0000000..e740ae9 --- /dev/null +++ b/src/mobileappconnector.h @@ -0,0 +1,22 @@ +#ifndef MOBILEAPPCONNECTOR_H +#define MOBILEAPPCONNECTOR_H + +#include + +namespace Ui { +class MobileAppConnector; +} + +class MobileAppConnector : public QDialog +{ + Q_OBJECT + +public: + explicit MobileAppConnector(QWidget *parent = nullptr); + ~MobileAppConnector(); + +private: + Ui::MobileAppConnector *ui; +}; + +#endif // MOBILEAPPCONNECTOR_H diff --git a/src/mobileappconnector.ui b/src/mobileappconnector.ui new file mode 100644 index 0000000..fa2578c --- /dev/null +++ b/src/mobileappconnector.ui @@ -0,0 +1,214 @@ + + + MobileAppConnector + + + + 0 + 0 + 800 + 530 + + + + Connect Mobile App + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + 0 + 0 + + + + Scan this QRCode from your ZecQT Wallet companion app to connect your phone + + + + + + + QR Code + + + + + + Connection String + + + + + + + + 9 + + + + true + + + + + + + + 0 + 0 + + + + background-color: #fff + + + + + + + + + + Allow connections over the internet via zec-qt-wallet wormhole + + + + + + + + + + ZecQT Wallet Companion App + + + + + + + 0 + 0 + + + + Disconnect + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + TextLabel + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Last seen: + + + + + + + TextLabel + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Connection type: + + + + + + + TextLabel + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + QRCodeLabel + QLabel +
qrcodelabel.h
+
+
+ + + + buttonBox + accepted() + MobileAppConnector + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + MobileAppConnector + reject() + + + 316 + 260 + + + 286 + 274 + + + + +
diff --git a/src/precompiled.h b/src/precompiled.h index 9d0fe75..3419af9 100644 --- a/src/precompiled.h +++ b/src/precompiled.h @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -67,6 +68,9 @@ #include "3rdparty/json/json.hpp" #include "3rdparty/qrcode/QrCode.hpp" +#define SODIUM_STATIC +#include "3rdparty/sodium.h" + #define QT6_VIRTUAL #endif diff --git a/src/qrcodelabel.cpp b/src/qrcodelabel.cpp index 1227d69..97f34c0 100644 --- a/src/qrcodelabel.cpp +++ b/src/qrcodelabel.cpp @@ -15,7 +15,7 @@ QSize QRCodeLabel::sizeHint() const void QRCodeLabel::resizeEvent(QResizeEvent*) { - if(!address.isEmpty()) + if(!str.isEmpty()) QLabel::setPixmap(scaledPixmap()); } @@ -24,7 +24,7 @@ QPixmap QRCodeLabel::scaledPixmap() const { pm.fill(Qt::white); QPainter painter(&pm); - qrcodegen::QrCode qr = qrcodegen::QrCode::encodeText(address.toUtf8().constData(), qrcodegen::QrCode::Ecc::LOW); + qrcodegen::QrCode qr = qrcodegen::QrCode::encodeText(str.toUtf8().constData(), qrcodegen::QrCode::Ecc::LOW); const int s = qr.getSize()>0?qr.getSize():1; const double w = pm.width(); const double h = pm.height(); @@ -51,7 +51,7 @@ QPixmap QRCodeLabel::scaledPixmap() const { return pm; } -void QRCodeLabel::setAddress(QString addr) { - address = addr; +void QRCodeLabel::setQrcodeString(QString stra) { + str = stra; QLabel::setPixmap(scaledPixmap()); } \ No newline at end of file diff --git a/src/qrcodelabel.h b/src/qrcodelabel.h index 9bf3abd..461b238 100644 --- a/src/qrcodelabel.h +++ b/src/qrcodelabel.h @@ -10,13 +10,13 @@ public: explicit QRCodeLabel(QWidget *parent = nullptr); virtual QSize sizeHint() const; - void setAddress(QString address); + void setQrcodeString(QString address); QPixmap scaledPixmap() const; public slots: void resizeEvent(QResizeEvent *); private: - QString address; + QString str; }; diff --git a/src/rpc.cpp b/src/rpc.cpp index 4c5c424..5f8276f 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -5,6 +5,7 @@ #include "senttxstore.h" #include "turnstile.h" #include "version.h" +#include "websockets.h" using json = nlohmann::json; @@ -65,6 +66,7 @@ RPC::~RPC() { delete allBalances; delete usedAddresses; delete zaddresses; + delete taddresses; delete conn; } @@ -86,13 +88,25 @@ void RPC::setConnection(Connection* c) { ui->statusBar->showMessage("Ready!"); refreshZECPrice(); - checkForUpdate(); + // Commented for Android beta. + // checkForUpdate(); // Force update, because this might be coming from a settings update // where we need to immediately refresh refresh(true); } +void RPC::getTAddresses(const std::function& cb) { + json payload = { + {"jsonrpc", "1.0"}, + {"id", "someid"}, + {"method", "getaddressesbyaccount"}, + {"params", {""}} + }; + + conn->doRPCWithDefaultErrorHandling(payload, cb); +} + void RPC::getZAddresses(const std::function& cb) { json payload = { {"jsonrpc", "1.0"}, @@ -530,6 +544,7 @@ void RPC::getInfoThenRefresh(bool force) { static int lastBlock = 0; int curBlock = reply["blocks"].get(); + int version = reply["version"].get(); if ( force || (curBlock != lastBlock) ) { // Something changed, so refresh everything. @@ -598,7 +613,7 @@ void RPC::getInfoThenRefresh(bool force) { // as the progress instead of verification progress. progress = (double)blockNumber / (double)estimatedheight; } - txt = txt % " ( " % QString::number(progress * 100, 'f', 0) % "% )"; + txt = txt % " ( " % QString::number(progress * 100, 'f', 2) % "% )"; ui->blockheight->setText(txt); ui->heightLabel->setText(QObject::tr("Downloading blocks")); } else { @@ -613,7 +628,7 @@ void RPC::getInfoThenRefresh(bool force) { " (" % (Settings::getInstance()->isTestnet() ? QObject::tr("testnet:") : "") % QString::number(blockNumber) % - (isSyncing ? ("/" % QString::number(progress*100, 'f', 0) % "%") : QString()) % + (isSyncing ? ("/" % QString::number(progress*100, 'f', 2) % "%") : QString()) % ")"; main->statusLabel->setText(statusText); @@ -625,6 +640,7 @@ void RPC::getInfoThenRefresh(bool force) { else { tooltip = QObject::tr("zcashd has no peer connections"); } + tooltip = tooltip % "(v " % QString::number(version) % ")"; if (!zecPrice.isEmpty()) { tooltip = "1 ZEC = " % zecPrice % "\n" % tooltip; @@ -667,6 +683,22 @@ void RPC::refreshAddresses() { refreshSentZTrans(); refreshReceivedZTrans(*zaddresses); }); + + delete taddresses; + taddresses = new QList(); + getTAddresses([=] (json reply) { + for (auto& it : reply.get()) { + auto addr = QString::fromStdString(it.get()); + if (Settings::isTAddress(addr)) + taddresses->push_back(addr); + } + + // If there are no t Addresses, create one + newTaddr([=] (json reply) { + // What if taddress gets deleted before this executes? + taddresses->append(QString::fromStdString(reply.get())); + }); + }); } // Function to create the data model and update the views, used below. @@ -676,21 +708,8 @@ void RPC::updateUI(bool anyUnconfirmed) { // Update balances model data, which will update the table too balancesTableModel->setNewData(allBalances, utxos); - // Add all the addresses into the inputs combo box - auto lastFromAddr = ui->inputsCombo->currentText(); - - ui->inputsCombo->clear(); - auto i = allBalances->constBegin(); - while (i != allBalances->constEnd()) { - ui->inputsCombo->addItem(i.key(), i.value()); - if (i.key() == lastFromAddr) ui->inputsCombo->setCurrentText(i.key()); - - ++i; - } - - if (lastFromAddr.isEmpty()) { - main->setDefaultPayFrom(); - } + // Update from address + main->updateFromCombo(); }; // Function to process reply of the listunspent and z_listunspent API calls, used below. @@ -719,17 +738,25 @@ void RPC::refreshBalances() { // 1. Get the Balances getBalance([=] (json reply) { - auto balT = QString::fromStdString(reply["transparent"]).toDouble(); - auto balZ = QString::fromStdString(reply["private"]).toDouble(); - auto tot = QString::fromStdString(reply["total"]).toDouble(); + auto balT = QString::fromStdString(reply["transparent"]).toDouble(); + auto balZ = QString::fromStdString(reply["private"]).toDouble(); + auto balTotal = QString::fromStdString(reply["total"]).toDouble(); + + AppDataModel::getInstance()->setBalances(balT, balZ); ui->balSheilded ->setText(Settings::getZECDisplayFormat(balZ)); ui->balTransparent->setText(Settings::getZECDisplayFormat(balT)); - ui->balTotal ->setText(Settings::getZECDisplayFormat(tot)); + ui->balTotal ->setText(Settings::getZECDisplayFormat(balTotal)); +<<<<<<< HEAD ui->balSheilded ->setToolTip(Settings::getUSDFromZecAmount(balZ)); ui->balTransparent->setToolTip(Settings::getUSDFromZecAmount(balT)); ui->balTotal ->setToolTip(Settings::getUSDFromZecAmount(tot)); +======= + ui->balSheilded ->setToolTip(Settings::getUSDFormat(balZ)); + ui->balTransparent->setToolTip(Settings::getUSDFormat(balT)); + ui->balTotal ->setToolTip(Settings::getUSDFormat(balTotal)); +>>>>>>> master }); // 2. Get the UTXOs @@ -963,8 +990,14 @@ void RPC::checkForUpdate(bool silent) { } auto currentVersion = QVersionNumber::fromString(APP_VERSION); + + // Get the max version that the user has hidden updates for + QSettings s; + auto maxHiddenVersion = QVersionNumber::fromString(s.value("update/lastversion", "0.0.0").toString()); + qDebug() << "Version check: Current " << currentVersion << ", Available " << maxVersion; - if (maxVersion > currentVersion) { + + if (maxVersion > currentVersion && maxVersion > maxHiddenVersion) { auto ans = QMessageBox::information(main, QObject::tr("Update Available"), QObject::tr("A new release v%1 is available! You have v%2.\n\nWould you like to visit the releases page?") .arg(maxVersion.toString()) @@ -972,6 +1005,9 @@ void RPC::checkForUpdate(bool silent) { QMessageBox::Yes, QMessageBox::Cancel); if (ans == QMessageBox::Yes) { QDesktopServices::openUrl(QUrl("https://github.com/ZcashFoundation/zec-qt-wallet/releases")); + } else { + // If the user selects cancel, don't bother them again for this version + s.setValue("update/lastversion", maxVersion.toString()); } } else { if (!silent) { @@ -979,7 +1015,7 @@ void RPC::checkForUpdate(bool silent) { QObject::tr("You already have the latest release v%1") .arg(currentVersion.toString())); } - } + } } } catch (...) { @@ -1045,7 +1081,7 @@ void RPC::refreshZECPrice() { void RPC::shutdownZcashd() { // Shutdown embedded zcashd if it was started - if (ezcashd == nullptr || conn == nullptr) { + if (ezcashd == nullptr || ezcashd->processId() == 0 || conn == nullptr) { // No zcashd running internally, just return return; } @@ -1086,8 +1122,18 @@ void RPC::shutdownZcashd() { }); waiter.start(1000); - // Wait for the zcash process to exit. - d.exec(); + // Wait for the zcash process to exit. + if (!Settings::getInstance()->isHeadless()) { + d.exec(); + } else { + while (waiter.isActive()) { + QCoreApplication::processEvents(); +#ifdef _WIN32 +#else + std::this_thread::sleep_for(std::chrono::seconds(1)); +#endif + } + } } @@ -1156,3 +1202,10 @@ QString RPC::getDefaultSaplingAddress() { return QString(); } + +QString RPC::getDefaultTAddress() { + if (getAllTAddresses()->length() > 0) + return getAllTAddresses()->at(0); + else + return QString(); +} \ No newline at end of file diff --git a/src/rpc.h b/src/rpc.h index 40c0b05..720f286 100644 --- a/src/rpc.h +++ b/src/rpc.h @@ -57,10 +57,13 @@ public: void fillTxJsonParams(json& params, Tx tx); void sendZTransaction(json params, const std::function& cb, const std::function& err); void watchTxStatus(); + + const QMap getWatchingTxns() { return watchingOps; } void addNewTxToWatch(const QString& newOpid, WatchedTx wtx); const TxTableModel* getTransactionsModel() { return transactionsTableModel; } const QList* getAllZAddresses() { return zaddresses; } + const QList* getAllTAddresses() { return taddresses; } const QList* getUTXOs() { return utxos; } const QMap* getAllBalances() { return allBalances; } const QMap* getUsedAddresses() { return usedAddresses; } @@ -77,6 +80,7 @@ public: void noConnection(); QString getDefaultSaplingAddress(); + QString getDefaultTAddress(); void getAllPrivKeys(const std::function>)>); @@ -101,6 +105,7 @@ private: void getZUnspent (const std::function& cb); void getTransactions (const std::function& cb); void getZAddresses (const std::function& cb); + void getTAddresses (const std::function& cb); Connection* conn = nullptr; QProcess* ezcashd = nullptr; @@ -109,6 +114,7 @@ private: QMap* allBalances = nullptr; QMap* usedAddresses = nullptr; QList* zaddresses = nullptr; + QList* taddresses = nullptr; QMap watchingOps; diff --git a/src/scripts/control b/src/scripts/control index c2147d4..d8b025b 100644 --- a/src/scripts/control +++ b/src/scripts/control @@ -3,7 +3,6 @@ Version: RELEASE_VERSION Section: base Priority: optional Architecture: amd64 -Depends: openssl (>= 1.0.0) Maintainer: Aditya Kulkarni Description: zec-qt-wallet is a full node and UI wallet for Zcash. zec-qt-wallet is a full node and UI wallet for Zcash. It comes with diff --git a/src/scripts/desktopentry b/src/scripts/desktopentry index a15092f..9925369 100644 --- a/src/scripts/desktopentry +++ b/src/scripts/desktopentry @@ -6,7 +6,7 @@ Exec=/usr/local/bin/zec-qt-wallet Icon=zec-qt-wallet.xpm Type=Application StartupNotify=true -StartupWMClass=Code +StartupWMClass=zecqtwallet Categories=Utility; MimeType=text/plain;inode/directory; Keywords=zec-qt-wallet; diff --git a/src/scripts/dounifiedbuild.ps1 b/src/scripts/dounifiedbuild.ps1 index 9dc4db0..0f0e2ed 100644 --- a/src/scripts/dounifiedbuild.ps1 +++ b/src/scripts/dounifiedbuild.ps1 @@ -61,11 +61,17 @@ ssh $winserver "New-Item zqwbuild -itemtype directory" | Out-Null # Same while copying the built msi. A straight scp pull from windows to here doesn't work, # so we ssh to windows, and then scp push the file to here. $myhostname = (hostname) | Out-String -NoNewline -Remove-Item -Path /tmp/zqwbuild -Recurse -ErrorAction Ignore | Out-Null -New-Item -Path /tmp/zqwbuild -itemtype directory | Out-Null -Copy-Item src /tmp/zqwbuild/ -Recurse -Copy-Item res /tmp/zqwbuild/ -Recurse -Copy-Item release /tmp/zqwbuild/ -Recurse +# Powershell seems not to be able to remove this directory for some reason! +# Remove-Item -Path /tmp/zqwbuild -Recurse -ErrorAction Ignore | Out-Null +bash "rm -rf /tmp/zqwbuild" 2>&1 | Out-Null +New-Item -Path /tmp/zqwbuild -itemtype directory -Force | Out-Null +Copy-Item src /tmp/zqwbuild/ -Recurse -Force +Copy-Item res /tmp/zqwbuild/ -Recurse -Force +Copy-Item release /tmp/zqwbuild/ -Recurse -Force + +# Remove some unnecessary stuff from the tmp directory to speed up copying +Remove-Item -Recurse -ErrorAction Ignore /tmp/zqwbuild/res/libsodium + ssh $winserver "scp -r ${myhostname}:/tmp/zqwbuild/* zqwbuild/" ssh $winserver "cd zqwbuild ; src/scripts/mkwininstaller.ps1 -version $version" >/dev/null if (!$?) { @@ -87,3 +93,7 @@ if (! (Test-Path ./artifacts/linux-binaries-zec-qt-wallet-v$version.tar.gz) -or exit 1; } Write-Host "[OK]" + +Write-Host -NoNewline "Signing Binaries......." +bash src/scripts/signbinaries.sh --version $version +Write-Host "[OK]" diff --git a/src/scripts/mkrelease.sh b/src/scripts/mkrelease.sh index dd88a5c..1b42ed5 100755 --- a/src/scripts/mkrelease.sh +++ b/src/scripts/mkrelease.sh @@ -66,6 +66,7 @@ echo "[OK]" echo -n "Building..............." rm -rf bin/zec-qt-wallet* > /dev/null +make clean > /dev/null make -j$(nproc) > /dev/null echo "[OK]" diff --git a/src/scripts/signbinaries.sh b/src/scripts/signbinaries.sh new file mode 100755 index 0000000..4f1dc77 --- /dev/null +++ b/src/scripts/signbinaries.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# Accept the variables as command line arguments as well +POSITIONAL=() +while [[ $# -gt 0 ]] +do +key="$1" + +case $key in + -v|--version) + APP_VERSION="$2" + shift # past argument + shift # past value + ;; + *) # unknown option + POSITIONAL+=("$1") # save it in an array for later + shift # past argument + ;; +esac +done +set -- "${POSITIONAL[@]}" # restore positional parameters + +if [ -z $APP_VERSION ]; then echo "APP_VERSION is not set"; exit 1; fi + +# Store the hash and signatures here +rm -rf release/signatures +mkdir -p release/signatures + +cd artifacts + +# Remove previous signatures/hashes +rm -f sha256sum-v$APP_VERSION.txt +rm -f signatures-v$APP_VERSION.tar.gz + +# sha256sum the binaries +gsha256sum *$APP_VERSION* > sha256sum-v$APP_VERSION.txt + +for i in $( ls *zec-qt-wallet-v$APP_VERSION* sha256sum-v$APP_VERSION* ); do + echo "Signing" $i + gpg --batch --output ../release/signatures/$i.sig --detach-sig $i +done + +mv sha256sum-v$APP_VERSION.txt ../release/signatures/ +cp ../res/SIGNATURES_README ../release/signatures/README + +cd ../release/signatures +tar -czf signatures-v$APP_VERSION.tar.gz * +mv signatures-v$APP_VERSION.tar.gz ../../artifacts + diff --git a/src/sendtab.cpp b/src/sendtab.cpp index 762987c..6cb7a86 100644 --- a/src/sendtab.cpp +++ b/src/sendtab.cpp @@ -12,8 +12,7 @@ using json = nlohmann::json; void MainWindow::setupSendTab() { // Create the validator for send to/amount fields - auto amtValidator = new QDoubleValidator(0, 21000000, 8, ui->Amount1); - amtValidator->setNotation(QDoubleValidator::StandardNotation); + auto amtValidator = new QRegExpValidator(QRegExp("[0-9]{0,8}\\.?[0-9]{0,8}")); ui->Amount1->setValidator(amtValidator); // Send button @@ -74,8 +73,7 @@ void MainWindow::setupSendTab() { } }); //Fees validator - auto feesValidator = new QDoubleValidator(0, 1, 8, ui->Amount1); - feesValidator->setNotation(QDoubleValidator::StandardNotation); + auto feesValidator = new QRegExpValidator(QRegExp("[0-9]{0,8}\\.?[0-9]{0,8}")); ui->minerFeeAmt->setValidator(feesValidator); // Font for the first Memo label @@ -101,6 +99,11 @@ void MainWindow::setupSendTab() { // Recurring schedule button QObject::connect(ui->btnRecurSchedule, &QPushButton::clicked, this, &MainWindow::editSchedule); + // Hide the recurring section for now + ui->chkRecurring->setVisible(false); + ui->lblRecurDesc->setVisible(false); + ui->btnRecurSchedule->setVisible(false); + // Set the default state for the whole page clearSendForm(); } @@ -173,6 +176,31 @@ void MainWindow::setDefaultPayFrom() { } }; +void MainWindow::updateFromCombo() { + if (!rpc || !rpc->getAllBalances()) + return; + + auto lastFromAddr = ui->inputsCombo->currentText(); + + ui->inputsCombo->clear(); + auto i = rpc->getAllBalances()->constBegin(); + + // Add all the addresses into the inputs combo box + while (i != rpc->getAllBalances()->constEnd()) { + ui->inputsCombo->addItem(i.key(), i.value()); + if (i.key() == lastFromAddr) ui->inputsCombo->setCurrentText(i.key()); + + ++i; + } + + if (lastFromAddr.isEmpty()) { + setDefaultPayFrom(); + } + else { + ui->inputsCombo->setCurrentText(lastFromAddr); + } +} + void MainWindow::inputComboTextChanged(int index) { auto addr = ui->inputsCombo->itemText(index); auto bal = rpc->getAllBalances()->value(addr); @@ -231,8 +259,9 @@ void MainWindow::addAddressSection() { Amount1->setPlaceholderText(tr("Amount")); Amount1->setObjectName(QString("Amount") % QString::number(itemNumber)); Amount1->setBaseSize(QSize(200, 0)); + Amount1->setAlignment(Qt::AlignRight); // Create the validator for send to/amount fields - auto amtValidator = new QDoubleValidator(0, 21000000, 8, Amount1); + auto amtValidator = new QRegExpValidator(QRegExp("[0-9]{0,8}\\.?[0-9]{0,8}")); Amount1->setValidator(amtValidator); QObject::connect(Amount1, &QLineEdit::textChanged, [=] (auto text) { this->amountChanged(itemNumber, text); diff --git a/src/senttxstore.cpp b/src/senttxstore.cpp index 9237a3c..3fc66ac 100644 --- a/src/senttxstore.cpp +++ b/src/senttxstore.cpp @@ -84,12 +84,22 @@ void SentTxStore::addToSentTx(Tx tx, QString txid) { totalAmount += i.amount; } + QString toAddresses; + if (tx.toAddrs.length() == 1) { + toAddresses = tx.toAddrs[0].addr; + } else { + // Concatenate all the toAddresses + for (auto a : tx.toAddrs) { + toAddresses += a.addr % "(" % Settings::getZECDisplayFormat(a.amount) % ") "; + } + } + auto list = jsonDoc.array(); QJsonObject txItem; txItem["type"] = "sent"; txItem["from"] = tx.fromAddr; txItem["datetime"] = QDateTime::currentMSecsSinceEpoch() / (qint64)1000; - txItem["address"] = QString(); // The sent address is blank, to be consistent with t-Addr sent behaviour + txItem["address"] = toAddresses; txItem["txid"] = txid; txItem["amount"] = -totalAmount; txItem["fee"] = -tx.fee; diff --git a/src/settings.h b/src/settings.h index fbadec0..af23cbd 100644 --- a/src/settings.h +++ b/src/settings.h @@ -34,6 +34,9 @@ public: void setUseEmbedded(bool r) { _useEmbedded = r; } bool useEmbedded() { return _useEmbedded; } + void setHeadless(bool h) { _headless = h; } + bool isHeadless() { return _headless; } + int getBlockNumber(); void setBlockNumber(int number); @@ -78,6 +81,8 @@ public: static double getMinerFee(); static double getZboardAmount(); static QString getZboardAddr(); + + static int getMaxMobileAppTxns() { return 30; } static bool isValidAddress(QString addr); @@ -103,8 +108,10 @@ private: bool _isSyncing = false; int _blockNumber = 0; bool _useEmbedded = false; + bool _headless = false; int _peerConnections = 0; - double zecPrice = 0.0; + + double zecPrice = 0.0; }; #endif // SETTINGS_H \ No newline at end of file diff --git a/src/turnstile.cpp b/src/turnstile.cpp index a94118d..df58b15 100644 --- a/src/turnstile.cpp +++ b/src/turnstile.cpp @@ -320,8 +320,10 @@ void Turnstile::executeMigrationStep() { return; } + // Sometimes, we check too quickly, and the unspent UTXO is not updated yet, so we'll + // double check to see if there is enough balance. if (!rpc->getAllBalances()->keys().contains(nextStep->intTAddr)) { - qDebug() << QString("The intermediate t-address doesn't have balance, even though it is confirmed"); + //qDebug() << QString("The intermediate t-address doesn't have balance, even though it seems to be confirmed"); return; } @@ -354,8 +356,9 @@ void Turnstile::doSendTx(Tx tx, std::function cb) { rpc->executeTransaction(tx, [=] (QString opid) { mainwindow->ui->statusBar->showMessage(QObject::tr("Computing Tx: ") % opid); }, - [=] (QString opid, QString txid) { + [=] (QString /*opid*/, QString txid) { mainwindow->ui->statusBar->showMessage(Settings::txidStatusMessage + " " + txid); + cb(); }, [=] (QString opid, QString errStr) { mainwindow->ui->statusBar->showMessage(QObject::tr(" Tx ") % opid % QObject::tr(" failed"), 15 * 1000); diff --git a/src/txtablemodel.cpp b/src/txtablemodel.cpp index 8b224b2..d028bb5 100644 --- a/src/txtablemodel.cpp +++ b/src/txtablemodel.cpp @@ -186,14 +186,30 @@ void TxTableModel::updateAllData() { return QVariant(); } -QString TxTableModel::getTxId(int row) { +QString TxTableModel::getTxId(int row) const { return modeldata->at(row).txid; } -QString TxTableModel::getMemo(int row) { +QString TxTableModel::getMemo(int row) const { return modeldata->at(row).memo; } -QString TxTableModel::getAddr(int row) { +qint64 TxTableModel::getConfirmations(int row) const { + return modeldata->at(row).confirmations; +} + +QString TxTableModel::getAddr(int row) const { return modeldata->at(row).address.trimmed(); +} + +qint64 TxTableModel::getDate(int row) const { + return modeldata->at(row).datetime; +} + +QString TxTableModel::getType(int row) const { + return modeldata->at(row).type; +} + +QString TxTableModel::getAmt(int row) const { + return Settings::getDecimalString(modeldata->at(row).amount); } \ No newline at end of file diff --git a/src/txtablemodel.h b/src/txtablemodel.h index a2e3e91..9c09a2c 100644 --- a/src/txtablemodel.h +++ b/src/txtablemodel.h @@ -15,9 +15,13 @@ public: void addZSentData(const QList& data); void addZRecvData(const QList& data); - QString getTxId(int row); - QString getMemo(int row); - QString getAddr(int row); + QString getTxId(int row) const; + QString getMemo(int row) const; + QString getAddr(int row) const; + qint64 getDate(int row) const; + QString getType(int row) const; + qint64 getConfirmations(int row) const; + QString getAmt (int row) const; bool exportToCsv(QString fileName) const; diff --git a/src/version.h b/src/version.h index ec5d866..0c11a4d 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define APP_VERSION "0.5.7" +#define APP_VERSION "0.6.1" diff --git a/src/websockets.cpp b/src/websockets.cpp new file mode 100644 index 0000000..1096133 --- /dev/null +++ b/src/websockets.cpp @@ -0,0 +1,803 @@ +#include "websockets.h" + +#include "rpc.h" +#include "settings.h" +#include "ui_mobileappconnector.h" +#include "version.h" + +WSServer::WSServer(quint16 port, bool debug, QObject *parent) : + QObject(parent), + m_pWebSocketServer(new QWebSocketServer(QStringLiteral("Direct Connection Server"), + QWebSocketServer::NonSecureMode, this)), + m_debug(debug) +{ + m_mainWindow = (MainWindow *) parent; + if (m_pWebSocketServer->listen(QHostAddress::AnyIPv4, port)) { + if (m_debug) + qDebug() << "Echoserver listening on port" << port; + connect(m_pWebSocketServer, &QWebSocketServer::newConnection, + this, &WSServer::onNewConnection); + connect(m_pWebSocketServer, &QWebSocketServer::closed, this, &WSServer::closed); + } +} + +WSServer::~WSServer() +{ + qDebug() << "Closing websocket"; + m_pWebSocketServer->close(); + qDeleteAll(m_clients.begin(), m_clients.end()); +} + +void WSServer::onNewConnection() +{ + QWebSocket *pSocket = m_pWebSocketServer->nextPendingConnection(); + + connect(pSocket, &QWebSocket::textMessageReceived, this, &WSServer::processTextMessage); + connect(pSocket, &QWebSocket::binaryMessageReceived, this, &WSServer::processBinaryMessage); + connect(pSocket, &QWebSocket::disconnected, this, &WSServer::socketDisconnected); + + m_clients << pSocket; +} + +void WSServer::processTextMessage(QString message) +{ + QWebSocket *pClient = qobject_cast(sender()); + if (m_debug) + qDebug() << "Message received:" << message; + + if (pClient) { + AppDataServer::getInstance()->processMessage(message, m_mainWindow, pClient, AppConnectionType::DIRECT); + } +} + +void WSServer::processBinaryMessage(QByteArray message) +{ + //QWebSocket *pClient = qobject_cast(sender()); + if (m_debug) + qDebug() << "Binary Message received:" << message; + +} + +void WSServer::socketDisconnected() +{ + QWebSocket *pClient = qobject_cast(sender()); + if (m_debug) + qDebug() << "socketDisconnected:" << pClient; + if (pClient) { + m_clients.removeAll(pClient); + pClient->deleteLater(); + } +} + +//=============================== +// WormholeClient +//=============================== +WormholeClient::WormholeClient(MainWindow* p, QString wormholeCode) { + this->parent = p; + this->code = wormholeCode; + connect(); +} + +WormholeClient::~WormholeClient() { + shuttingDown = true; + + if (m_webSocket->isValid()) { + m_webSocket->close(); + } + + if (timer) + timer->stop(); + + delete timer; +} + +void WormholeClient::connect() { + delete m_webSocket; + m_webSocket = new QWebSocket(); + + QObject::connect(m_webSocket, &QWebSocket::connected, this, &WormholeClient::onConnected); + QObject::connect(m_webSocket, &QWebSocket::disconnected, this, &WormholeClient::closed); + + m_webSocket->open(QUrl("wss://wormhole.zecqtwallet.com:443")); + //m_webSocket->open(QUrl("ws://127.0.0.1:7070")); +} + +void WormholeClient::retryConnect() { + QTimer::singleShot(5 * 1000 * pow(2, retryCount), [=]() { + if (retryCount < 10) { + qDebug() << "Retrying websocket connection"; + this->retryCount++; + connect(); + } + else { + qDebug() << "Retry count exceeded, will not attempt retry any more"; + } + }); +} + +// Called when the websocket is closed. If this was closed without our explicitly closing it, +// then we need to try and reconnect +void WormholeClient::closed() { + if (!shuttingDown) { + retryConnect(); + } +} + +void WormholeClient::onConnected() +{ + qDebug() << "WebSocket connected"; + retryCount = 0; + + QObject::connect(m_webSocket, &QWebSocket::textMessageReceived, + this, &WormholeClient::onTextMessageReceived); + + auto payload = QJsonDocument( QJsonObject { + {"register", code} + }).toJson(); + + m_webSocket->sendTextMessage(payload); + + // On connected, we'll also create a timer to ping it every 4 minutes, since the websocket + // will timeout after 5 minutes + timer = new QTimer(parent); + QObject::connect(timer, &QTimer::timeout, [=]() { + if (!shuttingDown && m_webSocket->isValid()) { + auto payload = QJsonDocument(QJsonObject { + {"ping", "ping"} + }).toJson(); + m_webSocket->sendTextMessage(payload); + } + }); + timer->start(4 * 60 * 1000); // 4 minutes +} + +void WormholeClient::onTextMessageReceived(QString message) +{ + AppDataServer::getInstance()->processMessage(message, parent, m_webSocket, AppConnectionType::INTERNET); +} + + +// ============================== +// AppDataServer +// ============================== +AppDataServer* AppDataServer::instance = nullptr; + +QString AppDataServer::getWormholeCode(QString secretHex) { + unsigned char* secret = new unsigned char[crypto_secretbox_KEYBYTES]; + sodium_hex2bin(secret, crypto_secretbox_KEYBYTES, secretHex.toStdString().c_str(), crypto_secretbox_KEYBYTES*2, + NULL, NULL, NULL); + + unsigned char* out1 = new unsigned char[crypto_hash_sha256_BYTES]; + crypto_hash_sha256(out1, secret, crypto_secretbox_KEYBYTES); + + unsigned char* out2 = new unsigned char[crypto_hash_sha256_BYTES]; + crypto_hash_sha256(out2, out1, crypto_hash_sha256_BYTES); + + char* wmcode = new char[crypto_hash_sha256_BYTES*2 + 1]; + sodium_bin2hex(wmcode, crypto_hash_sha256_BYTES*2 + 1, out2, crypto_hash_sha256_BYTES); + + QString wmcodehex(wmcode); + + delete[] wmcode; + delete[] out2; + delete[] out1; + delete[] secret; + + return wmcodehex; +} + +QString AppDataServer::getSecretHex() { + QSettings s; + + return s.value("mobileapp/secret", "").toString(); +} + +void AppDataServer::saveNewSecret(QString secretHex) { + QSettings().setValue("mobileapp/secret", secretHex); + + if (secretHex.isEmpty()) + setAllowInternetConnection(false); +} + +bool AppDataServer::getAllowInternetConnection() { + return QSettings().value("mobileapp/allowinternet", false).toBool(); +} + +void AppDataServer::setAllowInternetConnection(bool allow) { + QSettings().setValue("mobileapp/allowinternet", allow); +} + +void AppDataServer::saveLastConnectedOver(AppConnectionType type) { + QSettings().setValue("mobileapp/lastconnectedover", type); +} + +AppConnectionType AppDataServer::getLastConnectionType() { + return (AppConnectionType) QSettings().value("mobileapp/lastconnectedover", AppConnectionType::DIRECT).toInt(); +} + +void AppDataServer::saveLastSeenTime() { + QSettings().setValue("mobileapp/lastseentime", QDateTime::currentSecsSinceEpoch()); +} + +QDateTime AppDataServer::getLastSeenTime() { + return QDateTime::fromSecsSinceEpoch(QSettings().value("mobileapp/lastseentime", 0).toLongLong()); +} + +void AppDataServer::setConnectedName(QString name) { + QSettings().setValue("mobileapp/connectedname", name); +} + +QString AppDataServer::getConnectedName() { + return QSettings().value("mobileapp/connectedname", "").toString(); +} + +bool AppDataServer::isAppConnected() { + return !getConnectedName().isEmpty() && + getLastSeenTime().daysTo(QDateTime::currentDateTime()) < 14; +} + +void AppDataServer::connectAppDialog(MainWindow* parent) { + QDialog d(parent); + ui = new Ui_MobileAppConnector(); + ui->setupUi(&d); + Settings::saveRestore(&d); + + updateUIWithNewQRCode(parent); + updateConnectedUI(); + + QObject::connect(ui->btnDisconnect, &QPushButton::clicked, [=] () { + QSettings().setValue("mobileapp/connectedname", ""); + saveNewSecret(""); + + updateConnectedUI(); + }); + + QObject::connect(ui->txtConnStr, &QLineEdit::cursorPositionChanged, [=](int, int) { + ui->txtConnStr->selectAll(); + }); + + QObject::connect(ui->chkInternetConn, &QCheckBox::stateChanged, [=] (int state) { + if (state == Qt::Checked) { + + } + updateUIWithNewQRCode(parent); + }); + + // If we're not listening for the app, then start the websockets + if (!parent->isWebsocketListening()) { + QString wormholecode = ""; + if (getAllowInternetConnection()) + wormholecode = AppDataServer::getInstance()->getWormholeCode(AppDataServer::getInstance()->getSecretHex()); + + parent->createWebsocket(wormholecode); + } + + d.exec(); + + // If there is nothing connected when the dialog exits, then shutdown the websockets + if (!isAppConnected()) { + parent->stopWebsocket(); + } + + // Cleanup + tempSecret = ""; + + delete tempWormholeClient; + tempWormholeClient = nullptr; + + delete ui; + ui = nullptr; +} + +void AppDataServer::updateUIWithNewQRCode(MainWindow* mainwindow) { + // Get the address of the localhost + auto addrList = QNetworkInterface::allAddresses(); + + // Find a suitable address + QString ipv4Addr; + for (auto addr : addrList) { + if (addr.isLoopback() || addr.protocol() == QAbstractSocket::IPv6Protocol) + continue; + + ipv4Addr = addr.toString(); + break; + } + + if (ipv4Addr.isEmpty()) + return; + + QString uri = "ws://" + ipv4Addr + ":8237"; + + // Get a new secret + unsigned char* secretBin = new unsigned char[crypto_secretbox_KEYBYTES]; + randombytes_buf(secretBin, crypto_secretbox_KEYBYTES); + char* secretHex = new char[crypto_secretbox_KEYBYTES*2 + 1]; + sodium_bin2hex(secretHex, crypto_secretbox_KEYBYTES*2+1, secretBin, crypto_secretbox_KEYBYTES); + + QString secretStr(secretHex); + QString codeStr = uri + "," + secretStr; + + if (ui->chkInternetConn->isChecked()) { + codeStr = codeStr + ",1"; + } + + registerNewTempSecret(secretStr, ui->chkInternetConn->isChecked(), mainwindow); + + ui->qrcode->setQrcodeString(codeStr); + ui->txtConnStr->setText(codeStr); +} + +void AppDataServer::registerNewTempSecret(QString tmpSecretHex, bool allowInternet, MainWindow* main) { + tempSecret = tmpSecretHex; + + delete tempWormholeClient; + tempWormholeClient = nullptr; + + if (allowInternet) + tempWormholeClient = new WormholeClient(main, getWormholeCode(tempSecret)); +} + +QString AppDataServer::connDesc(AppConnectionType t) { + if (t == AppConnectionType::DIRECT) { + return QObject::tr("Connected directly"); + } + else { + return QObject::tr("Connected over the internet via zec-qt-wallet wormhole service"); + } +} + +void AppDataServer::updateConnectedUI() { + if (ui == nullptr) + return; + + auto remoteName = getConnectedName(); + + ui->lblRemoteName->setText(remoteName.isEmpty() ? "(Not connected to any device)" : remoteName); + ui->lblLastSeen->setText(remoteName.isEmpty() ? "" : getLastSeenTime().toString(Qt::SystemLocaleLongDate)); + ui->lblConnectionType->setText(remoteName.isEmpty() ? "" : connDesc(getLastConnectionType())); + + ui->btnDisconnect->setEnabled(!remoteName.isEmpty()); +} + +QString AppDataServer::getNonceHex(NonceType nt) { + QSettings s; + QString hex; + if (nt == NonceType::LOCAL) { + // The default local nonce starts from 1, to always keep it odd + auto defaultLocalNonce = "01" + QString("00").repeated(crypto_secretbox_NONCEBYTES-1); + hex = s.value("mobileapp/localnoncehex", defaultLocalNonce).toString(); + } + else { + hex = s.value("mobileapp/remotenoncehex", QString("00").repeated(crypto_secretbox_NONCEBYTES)).toString(); + } + return hex; +} + +void AppDataServer::saveNonceHex(NonceType nt, QString noncehex) { + QSettings s; + assert(noncehex.length() == crypto_secretbox_NONCEBYTES * 2); + if (nt == NonceType::LOCAL) { + s.setValue("mobileapp/localnoncehex", noncehex); + } + else { + s.setValue("mobileapp/remotenoncehex", noncehex); + } + s.sync(); +} + +// Encrypt an outgoing message with the stored secret key. +QString AppDataServer::encryptOutgoing(QString msg) { + if (msg.length() % 256 > 0) { + msg = msg + QString(" ").repeated(256 - (msg.length() % 256)); + } + + QString localNonceHex = getNonceHex(NonceType::LOCAL); + + unsigned char* noncebin = new unsigned char[crypto_secretbox_NONCEBYTES]; + sodium_hex2bin(noncebin, crypto_secretbox_NONCEBYTES, localNonceHex.toStdString().c_str(), localNonceHex.length(), + NULL, NULL, NULL); + + // Increment the nonce +2 and save + sodium_increment(noncebin, crypto_secretbox_NONCEBYTES); + sodium_increment(noncebin, crypto_secretbox_NONCEBYTES); + + char* newLocalNonce = new char[crypto_secretbox_NONCEBYTES*2 + 1]; + sodium_memzero(newLocalNonce, crypto_secretbox_NONCEBYTES*2 + 1); + sodium_bin2hex(newLocalNonce, crypto_secretbox_NONCEBYTES*2+1, noncebin, crypto_box_NONCEBYTES); + + saveNonceHex(NonceType::LOCAL, QString(newLocalNonce)); + + unsigned char* secret = new unsigned char[crypto_secretbox_KEYBYTES]; + sodium_hex2bin(secret, crypto_secretbox_KEYBYTES, getSecretHex().toStdString().c_str(), crypto_secretbox_KEYBYTES*2, + NULL, NULL, NULL); + + int msgSize = strlen(msg.toStdString().c_str()); + unsigned char* encrpyted = new unsigned char[ msgSize + crypto_secretbox_MACBYTES]; + + crypto_secretbox_easy(encrpyted, (const unsigned char *)msg.toStdString().c_str(), msgSize, noncebin, secret); + + int encryptedHexSize = (msgSize + crypto_secretbox_MACBYTES) * 2 + 1; + char * encryptedHex = new char[encryptedHexSize]; + sodium_memzero(encryptedHex, encryptedHexSize); + sodium_bin2hex(encryptedHex, encryptedHexSize, encrpyted, msgSize + crypto_secretbox_MACBYTES); + + auto json = QJsonDocument(QJsonObject{ + {"nonce", QString(newLocalNonce)}, + {"payload", QString(encryptedHex)}, + {"to", getWormholeCode(getSecretHex())} + }); + + delete[] noncebin; + delete[] newLocalNonce; + delete[] secret; + delete[] encrpyted; + delete[] encryptedHex; + + return json.toJson(); +} + +/** + Attempt to decrypt a message. If the decryption fails, it returns the string "error", the decrypted message otherwise. + It will use the given secret to attempt decryption. In addition, it will enforce that the nonce is greater than the last seen nonce, + unless the skipNonceCheck = true, which is used when attempting decrtption with a temp secret key. +*/ +QString AppDataServer::decryptMessage(QJsonDocument msg, QString secretHex, QString lastRemoteNonceHex) { + // Decrypt and then process + QString noncehex = msg.object().value("nonce").toString(); + QString encryptedhex = msg.object().value("payload").toString(); + + // Enforce limits on the size of the message + if (noncehex.length() > ((int)crypto_secretbox_NONCEBYTES * 2) || + encryptedhex.length() > 2 * 50 * 1024 /*50kb*/) { + return "error"; + } + + // Check to make sure that the nonce is greater than the last known remote nonce + unsigned char* lastRemoteBin = new unsigned char[crypto_secretbox_NONCEBYTES]; + sodium_hex2bin(lastRemoteBin, crypto_secretbox_NONCEBYTES, lastRemoteNonceHex.toStdString().c_str(), lastRemoteNonceHex.length(), + NULL, NULL, NULL); + + unsigned char* noncebin = new unsigned char[crypto_secretbox_NONCEBYTES]; + sodium_hex2bin(noncebin, crypto_secretbox_NONCEBYTES, noncehex.toStdString().c_str(), noncehex.length(), + NULL, NULL, NULL); + + assert(crypto_secretbox_KEYBYTES == crypto_hash_sha256_BYTES); + if (sodium_compare(lastRemoteBin, noncebin, crypto_secretbox_NONCEBYTES) != -1) { + // Refuse to accept a lower nonce, return an error + delete[] lastRemoteBin; + delete[] noncebin; + return "error"; + } + + unsigned char* secret = new unsigned char[crypto_secretbox_KEYBYTES]; + sodium_hex2bin(secret, crypto_secretbox_KEYBYTES, secretHex.toStdString().c_str(), crypto_secretbox_KEYBYTES*2, + NULL, NULL, NULL); + + unsigned char* encrypted = new unsigned char[encryptedhex.length() / 2]; + sodium_hex2bin(encrypted, encryptedhex.length() / 2, encryptedhex.toStdString().c_str(), encryptedhex.length(), + NULL, NULL, NULL); + + int decryptedLen = encryptedhex.length() / 2 - crypto_secretbox_MACBYTES; + unsigned char* decrypted = new unsigned char[decryptedLen]; + int result = crypto_secretbox_open_easy(decrypted, encrypted, encryptedhex.length() / 2, noncebin, secret); + + QString payload; + if (result == -1) { + payload = "error"; + } else { + // Update the last seen remote hex + saveNonceHex(NonceType::REMOTE, noncehex); + saveLastSeenTime(); + + char* decryptedStr = new char[decryptedLen + 1]; + sodium_memzero(decryptedStr, decryptedLen + 1); + memcpy(decryptedStr, decrypted, decryptedLen); + + payload = QString(decryptedStr); + + delete[] decryptedStr; + } + + delete[] secret; + delete[] lastRemoteBin; + delete[] noncebin; + delete[] encrypted; + delete[] decrypted; + + return payload; +} + +// Process an incoming text message. The message has to be encrypted with the secret key (or the temporary secret key) +void AppDataServer::processMessage(QString message, MainWindow* mainWindow, QWebSocket* pClient, AppConnectionType connType) { + auto replyWithError = [=]() { + auto r = QJsonDocument(QJsonObject{ + {"error", "Encryption error"}, + {"to", getWormholeCode(getSecretHex())} + }).toJson(); + pClient->sendTextMessage(r); + return; + }; + + // First, extract the command from the message + auto msg = QJsonDocument::fromJson(message.toUtf8()); + + // Check if we got an error from the websocket + if (msg.object().contains("error")) { + qDebug() << "Error:" << msg.toJson(); + return; + } + + // If the message is a ping, just ignore it + if (msg.object().contains("ping")) { + return; + } + + // Then, check if the message is encrpted + if (!msg.object().contains("nonce")) { + replyWithError(); + return; + } + + auto decrypted = decryptMessage(msg, getSecretHex(), getNonceHex(NonceType::REMOTE)); + + // If the decryption failed, maybe this is a new connection, so see if the dialog is open and a + // temp secret is in place + if (decrypted == "error") { + // If the dialog is open, then there might be a temporary, new secret key. Attempt to decrypt + // with that. + if (!tempSecret.isEmpty()) { + // Since this is a temp secret, the last seen nonce will be "0", so basically we'll accept any nonce + QString zeroNonce = QString("00").repeated(crypto_secretbox_NONCEBYTES); + decrypted = decryptMessage(msg, tempSecret, zeroNonce); + if (decrypted == "error") { + // Oh, well. Just return an error + replyWithError(); + return; + } + else { + // This is a new connection. So, update the the secret. Note the last seen remote nonce has already been updated by + // decryptMessage() + saveNewSecret(tempSecret); + setAllowInternetConnection(tempWormholeClient != nullptr); + + // Swap out the wormhole connection + mainWindow->replaceWormholeClient(tempWormholeClient); + tempWormholeClient = nullptr; + + saveLastConnectedOver(connType); + processDecryptedMessage(decrypted, mainWindow, pClient); + + // If the Connection UI is showing, we have to update the UI as well + if (ui != nullptr) { + // Update the connected phone information + updateConnectedUI(); + + // Update with a new QR Code for safety, so this secret isn't used by anyone else + updateUIWithNewQRCode(mainWindow); + } + + return; + } + } + else { + replyWithError(); + return; + } + } else { + saveLastConnectedOver(connType); + processDecryptedMessage(decrypted, mainWindow, pClient); + return; + } +} + +// Decrypted method will be executed here. +void AppDataServer::processDecryptedMessage(QString message, MainWindow* mainWindow, QWebSocket* pClient) { + // First, extract the command from the message + auto msg = QJsonDocument::fromJson(message.toUtf8()); + + if (!msg.object().contains("command")) { + auto r = QJsonDocument(QJsonObject{ + {"errorCode", -1}, + {"errorMessage", "Unknown JSON format"} + }).toJson(); + pClient->sendTextMessage(encryptOutgoing(r)); + return; + } + + if (msg.object()["command"] == "getInfo") { + processGetInfo(msg.object(), mainWindow, pClient); + } + else if (msg.object()["command"] == "getTransactions") { + processGetTransactions(mainWindow, pClient); + } + else if (msg.object()["command"] == "sendTx") { + processSendTx(msg.object()["tx"].toObject(), mainWindow, pClient); + } + else { + auto r = QJsonDocument(QJsonObject{ + {"errorCode", -1}, + {"errorMessage", "Command not found:" + msg.object()["command"].toString()} + }).toJson(); + pClient->sendTextMessage(encryptOutgoing(r)); + } +} + +// "sendTx" command. This method will actually send money, so be careful with everything +void AppDataServer::processSendTx(QJsonObject sendTx, MainWindow* mainwindow, QWebSocket* pClient) { + auto error = [=](QString reason) { + auto r = QJsonDocument(QJsonObject{ + {"errorCode", -1}, + {"errorMessage", "Couldn't send Tx:" + reason} + }).toJson(); + pClient->sendTextMessage(encryptOutgoing(r)); + return; + }; + + // Refuse to send if the node is still syncing + if (Settings::getInstance()->isSyncing()) { + error(QObject::tr("Node is still syncing.")); + return; + } + + // Create a Tx Object + Tx tx; + tx.fee = Settings::getMinerFee(); + + // Find a from address that has at least the sending amout + double amt = sendTx["amount"].toString().toDouble(); + auto allBalances = mainwindow->getRPC()->getAllBalances(); + QList> bals; + for (auto i : allBalances->keys()) { + // Filter out sprout addresses + if (Settings::getInstance()->isSproutAddress(i)) + continue; + // Filter out balances that don't have the requisite amount + if (allBalances->value(i) < amt) + continue; + + bals.append(QPair(i, allBalances->value(i))); + } + + if (bals.isEmpty()) { + error(QObject::tr("No sapling or transparent addresses with enough balance to spend.")); + return; + } + + std::sort(bals.begin(), bals.end(), [=](const QPaira, const QPair b) -> bool { + // Sort z addresses first + return a.first > b.first; + }); + + tx.fromAddr = bals[0].first; + tx.toAddrs = { ToFields{ sendTx["to"].toString(), amt, sendTx["memo"].toString(), sendTx["memo"].toString().toUtf8().toHex()} }; + + // TODO: Respect the autoshield change setting + + QString validation = mainwindow->doSendTxValidations(tx); + if (!validation.isEmpty()) { + error(validation); + return; + } + + json params = json::array(); + mainwindow->getRPC()->fillTxJsonParams(params, tx); + std::cout << std::setw(2) << params << std::endl; + + // And send the Tx + mainwindow->getRPC()->executeTransaction(tx, + [=] (QString) {}, + // Submitted Tx successfully + [=] (QString, QString txid) { + auto r = QJsonDocument(QJsonObject{ + {"version", 1.0}, + {"command", "sendTxSubmitted"}, + {"txid", txid} + }).toJson(); + if (pClient->isValid()) + pClient->sendTextMessage(encryptOutgoing(r)); + }, + // Errored while submitting Tx + [=] (QString, QString errStr) { + auto r = QJsonDocument(QJsonObject{ + {"version", 1.0}, + {"command", "sendTxFailed"}, + {"err", errStr} + }).toJson(); + if (pClient->isValid()) + pClient->sendTextMessage(encryptOutgoing(r)); + } + ); + + auto r = QJsonDocument(QJsonObject{ + {"version", 1.0}, + {"command", "sendTx"}, + {"result", "success"} + }).toJson(); + pClient->sendTextMessage(encryptOutgoing(r)); +} + +// "getInfo" command +void AppDataServer::processGetInfo(QJsonObject jobj, MainWindow* mainWindow, QWebSocket* pClient) { + auto connectedName = jobj["name"].toString(); + + if (mainWindow == nullptr || mainWindow->getRPC() == nullptr || + mainWindow->getRPC()->getAllBalances() == nullptr) { + pClient->close(QWebSocketProtocol::CloseCodeNormal, "Not yet ready"); + return; + } + + + // Max spendable safely from a z address and from any address + double maxZSpendable = 0; + double maxSpendable = 0; + for (auto a : mainWindow->getRPC()->getAllBalances()->keys()) { + if (Settings::getInstance()->isSaplingAddress(a)) { + if (mainWindow->getRPC()->getAllBalances()->value(a) > maxZSpendable) { + maxZSpendable = mainWindow->getRPC()->getAllBalances()->value(a); + } + } + if (mainWindow->getRPC()->getAllBalances()->value(a) > maxSpendable) { + maxSpendable = mainWindow->getRPC()->getAllBalances()->value(a); + } + } + + setConnectedName(connectedName); + + auto r = QJsonDocument(QJsonObject{ + {"version", 1.0}, + {"command", "getInfo"}, + {"saplingAddress", mainWindow->getRPC()->getDefaultSaplingAddress()}, + {"tAddress", mainWindow->getRPC()->getDefaultTAddress()}, + {"balance", AppDataModel::getInstance()->getTotalBalance()}, + {"maxspendable", maxSpendable}, + {"maxzspendable", maxZSpendable}, + {"tokenName", Settings::getTokenName()}, + {"zecprice", Settings::getInstance()->getZECPrice()}, + {"serverversion", QString(APP_VERSION)} + }).toJson(); + pClient->sendTextMessage(encryptOutgoing(r)); +} + +void AppDataServer::processGetTransactions(MainWindow* mainWindow, QWebSocket* pClient) { + QJsonArray txns; + auto model = mainWindow->getRPC()->getTransactionsModel(); + + // Manually add pending ops, so that computing transactions will also show up + auto wtxns = mainWindow->getRPC()->getWatchingTxns(); + for (auto opid : wtxns.keys()) { + txns.append(QJsonObject{ + {"type", "send"}, + {"datetime", QDateTime::currentSecsSinceEpoch()}, + {"amount", Settings::getDecimalString(wtxns[opid].tx.toAddrs[0].amount)}, + {"txid", ""}, + {"address", wtxns[opid].tx.toAddrs[0].addr}, + {"memo", wtxns[opid].tx.toAddrs[0].txtMemo}, + {"confirmations", 0} + }); + } + + // Add transactions + for (int i = 0; i < model->rowCount(QModelIndex()) && i < Settings::getMaxMobileAppTxns(); i++) { + txns.append(QJsonObject{ + {"type", model->getType(i)}, + {"datetime", model->getDate(i)}, + {"amount", model->getAmt(i)}, + {"txid", model->getTxId(i)}, + {"address", model->getAddr(i)}, + {"memo", model->getMemo(i)}, + {"confirmations", model->getConfirmations(i)} + }); + } + + auto r = QJsonDocument(QJsonObject{ + {"version", 1.0}, + {"command", "getTransactions"}, + {"transactions", txns} + }).toJson(); + pClient->sendTextMessage(encryptOutgoing(r)); +} + +// ============================== +// AppDataModel +// ============================== +AppDataModel* AppDataModel::instance = nullptr; diff --git a/src/websockets.h b/src/websockets.h new file mode 100644 index 0000000..c5b7d56 --- /dev/null +++ b/src/websockets.h @@ -0,0 +1,161 @@ +#ifndef WEBSOCKETS_H +#define WEBSOCKETS_H + +#include "precompiled.h" + +#include "mainwindow.h" +#include "ui_mobileappconnector.h" + + +QT_FORWARD_DECLARE_CLASS(QWebSocketServer) +QT_FORWARD_DECLARE_CLASS(QWebSocket) + +class WSServer : public QObject +{ + Q_OBJECT +public: + explicit WSServer(quint16 port, bool debug = false, QObject *parent = nullptr); + ~WSServer(); + +Q_SIGNALS: + void closed(); + +private Q_SLOTS: + void onNewConnection(); + void processTextMessage(QString message); + void processBinaryMessage(QByteArray message); + void socketDisconnected(); + +private: + QWebSocketServer *m_pWebSocketServer; + MainWindow *m_mainWindow; + QList m_clients; + bool m_debug; +}; + +class WormholeClient : public QObject { + Q_OBJECT + +private Q_SLOTS: + void onConnected(); + void onTextMessageReceived(QString message); + void closed(); + +public: + WormholeClient(MainWindow* parent, QString wormholeCode); + ~WormholeClient(); + + void connect(); + void retryConnect(); + +private: + MainWindow* parent = nullptr; + QWebSocket* m_webSocket = nullptr; + + QTimer* timer = nullptr; + + QString code; + int retryCount = 0; + bool shuttingDown = false; +}; + +enum NonceType { + LOCAL = 1, + REMOTE +}; + +enum AppConnectionType { + DIRECT = 1, + INTERNET +}; + +class AppDataServer { +public: + static AppDataServer* getInstance() { + if (instance == nullptr) { + instance = new AppDataServer(); + } + return instance; + } + + void connectAppDialog(MainWindow* parent); + void updateConnectedUI(); + void updateUIWithNewQRCode(MainWindow* mainwindow); + + void processSendTx(QJsonObject sendTx, MainWindow* mainwindow, QWebSocket* pClient); + void processMessage(QString message, MainWindow* mainWindow, QWebSocket* pClient, AppConnectionType connType); + void processGetInfo(QJsonObject jobj, MainWindow* mainWindow, QWebSocket* pClient); + void processDecryptedMessage(QString message, MainWindow* mainWindow, QWebSocket* pClient); + void processGetTransactions(MainWindow* mainWindow, QWebSocket* pClient); + + QString decryptMessage(QJsonDocument msg, QString secretHex, QString lastRemoteNonceHex); + QString encryptOutgoing(QString msg); + + QString getWormholeCode(QString secretHex); + QString getSecretHex(); + void saveNewSecret(QString secretHex); + + void registerNewTempSecret(QString tmpSecretHex, bool allowInternet, MainWindow* main); + + QString getNonceHex(NonceType nt); + void saveNonceHex(NonceType nt, QString noncehex); + + bool getAllowInternetConnection(); + void setAllowInternetConnection(bool allow); + + void saveLastSeenTime(); + QDateTime getLastSeenTime(); + + void setConnectedName(QString name); + QString getConnectedName(); + bool isAppConnected(); + + QString connDesc(AppConnectionType t); + + void saveLastConnectedOver(AppConnectionType type); + AppConnectionType getLastConnectionType(); + +private: + AppDataServer() = default; + + static AppDataServer* instance; + Ui_MobileAppConnector* ui; + + QString tempSecret; + WormholeClient* tempWormholeClient = nullptr; +}; + +class AppDataModel { +public: + static AppDataModel* getInstance() { + if (instance == NULL) + instance = new AppDataModel(); + + return instance; + } + + double getTBalance() { return balTransparent; } + double getZBalance() { return balShielded; } + double getTotalBalance() { return balTotal; } + + void setBalances(double transparent, double shielded) { + balTransparent = transparent; + balShielded = shielded; + balTotal = balTransparent + balShielded; + } + +private: + AppDataModel() = default; // Private, for singleton + + double balTransparent; + double balShielded; + double balTotal; + + QString saplingAddress; + + static AppDataModel* instance; +}; + + + +#endif // WEBSOCKETS_H \ No newline at end of file diff --git a/wsclient.html b/wsclient.html new file mode 100644 index 0000000..e6d22cd --- /dev/null +++ b/wsclient.html @@ -0,0 +1,102 @@ + + + WebSocket Echo Client + + +

WebSocket Echo Client

+

+ + + +

+

+ +

+

+ + +

+ + + + diff --git a/zec-qt-wallet.pro b/zec-qt-wallet.pro index 1d9c835..d1db8c6 100644 --- a/zec-qt-wallet.pro +++ b/zec-qt-wallet.pro @@ -10,7 +10,8 @@ CONFIG += precompile_header PRECOMPILED_HEADER = src/precompiled.h -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +QT += widgets +QT += websockets TARGET = zec-qt-wallet @@ -45,13 +46,15 @@ SOURCES += \ src/sendtab.cpp \ src/senttxstore.cpp \ src/txtablemodel.cpp \ - src/turnstile.cpp \ + src/turnstile.cpp \ src/qrcodelabel.cpp \ src/connection.cpp \ src/fillediconlabel.cpp \ src/addressbook.cpp \ src/logger.cpp \ src/addresscombo.cpp \ + src/websockets.cpp \ + src/mobileappconnector.cpp \ src/recurring.cpp HEADERS += \ @@ -66,13 +69,15 @@ HEADERS += \ src/settings.h \ src/txtablemodel.h \ src/senttxstore.h \ - src/turnstile.h \ + src/turnstile.h \ src/qrcodelabel.h \ src/connection.h \ src/fillediconlabel.h \ src/addressbook.h \ src/logger.h \ src/addresscombo.h \ + src/websockets.h \ + src/mobileappconnector.h \ src/recurring.h FORMS += \ @@ -87,6 +92,8 @@ FORMS += \ src/connection.ui \ src/zboard.ui \ src/addressbook.ui \ + src/mobileappconnector.ui \ + src/createzcashconfdialog.ui \ src/recurringdialog.ui \ src/newrecurring.ui @@ -94,14 +101,32 @@ FORMS += \ TRANSLATIONS = res/zec_qt_wallet_es.ts \ res/zec_qt_wallet_fr.ts \ res/zec_qt_wallet_de.ts \ - res/zec_qt_wallet_pt.ts + res/zec_qt_wallet_pt.ts \ + res/zec_qt_wallet_it.ts win32: RC_ICONS = res/icon.ico ICON = res/logo.icns +libsodium.target = $$PWD/res/libsodium.a +libsodium.commands = res/libsodium/buildlibsodium.sh + +QMAKE_EXTRA_TARGETS += libsodium +QMAKE_CLEAN += res/libsodium.a # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target +win32:CONFIG(release, debug|release): LIBS += -L$$PWD/res/ -llibsodium +else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/res/ -llibsodiumd +else:unix: LIBS += -L$$PWD/res/ -lsodium + +INCLUDEPATH += $$PWD/res +DEPENDPATH += $$PWD/res + +win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/res/liblibsodium.a +else:win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/res/liblibsodium.a +else:win32:!win32-g++:CONFIG(release, debug|release): PRE_TARGETDEPS += $$PWD/res/libsodium.lib +else:win32:!win32-g++:CONFIG(debug, debug|release): PRE_TARGETDEPS += $$PWD/res/libsodiumd.lib +else:unix: PRE_TARGETDEPS += $$PWD/res/libsodium.a