Merge branch 'duke' into dev

This commit is contained in:
Jonathan "Duke" Leto
2019-06-18 06:46:45 -07:00
4 changed files with 30 additions and 51 deletions

View File

@@ -1,5 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2019 The Hush developers
// Distributed under the MIT software license, see the accompanying // Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -752,15 +753,11 @@ static void ZC_LoadParams(
struct timeval tv_start, tv_end; struct timeval tv_start, tv_end;
float elapsed; float elapsed;
boost::filesystem::path pk_path = ZC_GetParamsDir() / "sprout-proving.key";
boost::filesystem::path vk_path = ZC_GetParamsDir() / "sprout-verifying.key";
boost::filesystem::path sapling_spend = ZC_GetParamsDir() / "sapling-spend.params"; boost::filesystem::path sapling_spend = ZC_GetParamsDir() / "sapling-spend.params";
boost::filesystem::path sapling_output = ZC_GetParamsDir() / "sapling-output.params"; boost::filesystem::path sapling_output = ZC_GetParamsDir() / "sapling-output.params";
boost::filesystem::path sprout_groth16 = ZC_GetParamsDir() / "sprout-groth16.params"; boost::filesystem::path sprout_groth16 = ZC_GetParamsDir() / "sprout-groth16.params";
if (!( if (!(
boost::filesystem::exists(pk_path) &&
boost::filesystem::exists(vk_path) &&
boost::filesystem::exists(sapling_spend) && boost::filesystem::exists(sapling_spend) &&
boost::filesystem::exists(sapling_output) && boost::filesystem::exists(sapling_output) &&
boost::filesystem::exists(sprout_groth16) boost::filesystem::exists(sprout_groth16)
@@ -775,18 +772,17 @@ static void ZC_LoadParams(
return; return;
} }
LogPrintf("Loading verifying key from %s\n", vk_path.string().c_str()); //LogPrintf("Loading verifying key from %s\n", vk_path.string().c_str());
gettimeofday(&tv_start, 0); gettimeofday(&tv_start, 0);
pzcashParams = ZCJoinSplit::Prepared(vk_path.string(), pk_path.string()); //pzcashParams = ZCJoinSplit::Prepared(vk_path.string(), pk_path.string());
gettimeofday(&tv_end, 0); gettimeofday(&tv_end, 0);
elapsed = float(tv_end.tv_sec-tv_start.tv_sec) + (tv_end.tv_usec-tv_start.tv_usec)/float(1000000); elapsed = float(tv_end.tv_sec-tv_start.tv_sec) + (tv_end.tv_usec-tv_start.tv_usec)/float(1000000);
LogPrintf("Loaded verifying key in %fs seconds.\n", elapsed); LogPrintf("Loaded verifying key in %fs seconds.\n", elapsed);
static_assert( static_assert( sizeof(boost::filesystem::path::value_type) == sizeof(codeunit), "librustzcash not configured correctly");
sizeof(boost::filesystem::path::value_type) == sizeof(codeunit),
"librustzcash not configured correctly");
auto sapling_spend_str = sapling_spend.native(); auto sapling_spend_str = sapling_spend.native();
auto sapling_output_str = sapling_output.native(); auto sapling_output_str = sapling_output.native();
auto sprout_groth16_str = sprout_groth16.native(); auto sprout_groth16_str = sprout_groth16.native();
@@ -796,6 +792,7 @@ static void ZC_LoadParams(
LogPrintf("Loading Sapling (Sprout Groth16) parameters from %s\n", sprout_groth16.string().c_str()); LogPrintf("Loading Sapling (Sprout Groth16) parameters from %s\n", sprout_groth16.string().c_str());
gettimeofday(&tv_start, 0); gettimeofday(&tv_start, 0);
// TODO: Unfortunately there is no way to initialize things without groth16, unless Rust code is modified.
librustzcash_init_zksnark_params( librustzcash_init_zksnark_params(
reinterpret_cast<const codeunit*>(sapling_spend_str.c_str()), reinterpret_cast<const codeunit*>(sapling_spend_str.c_str()),
sapling_spend_str.length(), sapling_spend_str.length(),

View File

@@ -1692,7 +1692,7 @@ int8_t equihash_params_possible(uint64_t n, uint64_t k)
void komodo_args(char *argv0) void komodo_args(char *argv0)
{ {
std::string name,addn,hexstr,symbol; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[32756],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz=0,baseid,len,n,extralen = 0; uint64_t ccenables[256], ccEnablesHeight[512]; std::string name,addn,hexstr,symbol; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[32756],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz=0,baseid,len,n,extralen = 0; uint64_t ccenables[256], ccEnablesHeight[512] = {0};
IS_KOMODO_NOTARY = GetBoolArg("-notary", false); IS_KOMODO_NOTARY = GetBoolArg("-notary", false);
IS_STAKED_NOTARY = GetArg("-stakednotary", -1); IS_STAKED_NOTARY = GetArg("-stakednotary", -1);
memset(ccenables,0,sizeof(ccenables)); memset(ccenables,0,sizeof(ccenables));
@@ -1767,7 +1767,7 @@ void komodo_args(char *argv0)
{ {
int32_t ecode = ccEnablesHeight[i]; int32_t ecode = ccEnablesHeight[i];
int32_t ht = ccEnablesHeight[i+1]; int32_t ht = ccEnablesHeight[i+1];
if ( ecode > 256 ) if ( ecode > 256 || ecode < 0 )
fprintf(stderr, "ac_ccactivateht: invalid evalcode.%i must be between 0 and 256.\n", ecode); fprintf(stderr, "ac_ccactivateht: invalid evalcode.%i must be between 0 and 256.\n", ecode);
else if ( ht > 0 ) else if ( ht > 0 )
{ {

View File

@@ -4,26 +4,14 @@ cd %THIS_DIR%
IF NOT EXIST %APPDATA%\ZcashParams ( IF NOT EXIST %APPDATA%\ZcashParams (
MKDIR %APPDATA%\ZcashParams MKDIR %APPDATA%\ZcashParams
) )
IF NOT EXIST %APPDATA%\ZcashParams\sprout-proving.key (
ECHO Downloading Zcash trusted setup sprout-proving.key, this may take a while ...
.\wget64.exe --progress=dot:giga --continue --retry-connrefused --waitretry=3 --timeout=30 https://z.cash/downloads/sprout-proving.key -O %APPDATA%\ZcashParams\sprout-proving.key
)
IF NOT EXIST %APPDATA%\ZcashParams\sprout-verifying.key (
ECHO Downloading Zcash trusted setup sprout-verifying.key, this may take a while ...
.\wget64.exe --progress=dot:giga --continue --retry-connrefused --waitretry=3 --timeout=30 https://z.cash/downloads/sprout-verifying.key -O %APPDATA%\ZcashParams\sprout-verifying.key
)
IF NOT EXIST %APPDATA%\ZcashParams\sapling-spend.params ( IF NOT EXIST %APPDATA%\ZcashParams\sapling-spend.params (
ECHO Downloading Zcash trusted setup sprout-proving.key, this may take a while ... ECHO Downloading Zcash trusted setup sapling-spend.key, this may take a while ...
.\wget64.exe --progress=dot:giga --continue --retry-connrefused --waitretry=3 --timeout=30 https://z.cash/downloads/sapling-spend.params -O %APPDATA%\ZcashParams\sapling-spend.params .\wget64.exe --progress=dot:giga --continue --retry-connrefused --waitretry=3 --timeout=30 https://z.cash/downloads/sapling-spend.params -O %APPDATA%\ZcashParams\sapling-spend.params
) )
IF NOT EXIST %APPDATA%\ZcashParams\sapling-output.params ( IF NOT EXIST %APPDATA%\ZcashParams\sapling-output.params (
ECHO Downloading Zcash trusted setup sprout-verifying.key, this may take a while ... ECHO Downloading Zcash trusted setup sapling-output.key, this may take a while ...
.\wget64.exe --progress=dot:giga --continue --retry-connrefused --waitretry=3 --timeout=30 https://z.cash/downloads/sapling-output.params -O %APPDATA%\ZcashParams\sapling-output.params .\wget64.exe --progress=dot:giga --continue --retry-connrefused --waitretry=3 --timeout=30 https://z.cash/downloads/sapling-output.params -O %APPDATA%\ZcashParams\sapling-output.params
) )
IF NOT EXIST %APPDATA%\ZcashParams\sprout-groth16.params (
ECHO Downloading Zcash trusted setup sprout-verifying.key, this may take a while ...
.\wget64.exe --progress=dot:giga --continue --retry-connrefused --waitretry=3 --timeout=30 https://z.cash/downloads/sprout-groth16.params -O %APPDATA%\ZcashParams\sprout-groth16.params
)
goto :EOF goto :EOF
:GET_CURRENT_DIR :GET_CURRENT_DIR
pushd %~dp0 pushd %~dp0

View File

@@ -1,20 +1,20 @@
#!/bin/bash #!/bin/bash
# Copyright 2019 The Hush developers
set -eu set -eu
# We do not declare our own location because we can use the params
# from any other installed coins
if [[ "$OSTYPE" == "darwin"* ]]; then if [[ "$OSTYPE" == "darwin"* ]]; then
PARAMS_DIR="$HOME/Library/Application Support/ZcashParams" PARAMS_DIR="$HOME/Library/Application Support/ZcashParams"
else else
PARAMS_DIR="$HOME/.zcash-params" PARAMS_DIR="$HOME/.zcash-params"
fi fi
SPROUT_PKEY_NAME='sprout-proving.key'
SPROUT_VKEY_NAME='sprout-verifying.key'
SAPLING_SPEND_NAME='sapling-spend.params' SAPLING_SPEND_NAME='sapling-spend.params'
SAPLING_OUTPUT_NAME='sapling-output.params' SAPLING_OUTPUT_NAME='sapling-output.params'
SAPLING_SPROUT_GROTH16_NAME='sprout-groth16.params' URL="https://z.cash/downloads"
SPROUT_URL="https://z.cash/downloads" IPFS="/ipfs/QmZKKx7Xup7LiAtFRhYsE1M7waXcv9ir9eCECyXAFGxhEo"
SPROUT_IPFS="/ipfs/QmZKKx7Xup7LiAtFRhYsE1M7waXcv9ir9eCECyXAFGxhEo"
SHA256CMD="$(command -v sha256sum || echo shasum)" SHA256CMD="$(command -v sha256sum || echo shasum)"
SHA256ARGS="$(command -v sha256sum >/dev/null || echo '-a 256')" SHA256ARGS="$(command -v sha256sum >/dev/null || echo '-a 256')"
@@ -38,7 +38,7 @@ function fetch_wget {
cat <<EOF cat <<EOF
Retrieving (wget): $SPROUT_URL/$filename Retrieving (wget): $URL/$filename
EOF EOF
wget \ wget \
@@ -46,7 +46,7 @@ EOF
--output-document="$dlname" \ --output-document="$dlname" \
--continue \ --continue \
--retry-connrefused --waitretry=3 --timeout=30 \ --retry-connrefused --waitretry=3 --timeout=30 \
"$SPROUT_URL/$filename" "$URL/$filename"
} }
function fetch_ipfs { function fetch_ipfs {
@@ -59,10 +59,10 @@ function fetch_ipfs {
cat <<EOF cat <<EOF
Retrieving (ipfs): $SPROUT_IPFS/$filename Retrieving (ipfs): $IPFS/$filename
EOF EOF
ipfs get --output "$dlname" "$SPROUT_IPFS/$filename" ipfs get --output "$dlname" "$IPFS/$filename"
} }
function fetch_curl { function fetch_curl {
@@ -75,13 +75,13 @@ function fetch_curl {
cat <<EOF cat <<EOF
Retrieving (curl): $SPROUT_URL/$filename Retrieving (curl): $URL/$filename
EOF EOF
curl \ curl \
--output "$dlname" \ --output "$dlname" \
-# -L -C - \ -# -L -C - \
"$SPROUT_URL/$filename" "$URL/$filename"
} }
@@ -159,30 +159,29 @@ function main() {
|| exit_locked_error || exit_locked_error
cat <<EOF cat <<EOF
Zcash - fetch-params.sh Hush - fetch-params.sh
This script will fetch the Zcash zkSNARK parameters and verify their This script will fetch the zkSNARK parameters used in shield
integrity with sha256sum. transactions and verify their integrity with sha256sum.
If they already exist locally, it will exit now and do nothing else. If they already exist locally, it will exit now and do nothing else.
EOF EOF
# Now create PARAMS_DIR and insert a README if necessary: # Now create PARAMS_DIR and insert a README if necessary:
if ! [ -d "$PARAMS_DIR" ] if ! [ -d "$PARAMS_DIR" ]; then
then
mkdir -p "$PARAMS_DIR" mkdir -p "$PARAMS_DIR"
README_PATH="$PARAMS_DIR/README" README_PATH="$PARAMS_DIR/README"
cat >> "$README_PATH" <<EOF cat >> "$README_PATH" <<EOF
This directory stores common Zcash zkSNARK parameters. Note that it is This directory stores common zkSNARK parameters needed for shielded
distinct from the daemon's -datadir argument because the parameters are transactions. Note that it is distinct from the daemon's -datadir argument
large and may be shared across multiple distinct -datadir's such as when because the parameters are large and may be shared across multiple distinct
setting up test networks. -datadir's such as when setting up test networks.
EOF EOF
# This may be the first time the user's run this script, so give # This may be the first time the user's run this script, so give
# them some info, especially about bandwidth usage: # them some info, especially about bandwidth usage:
cat <<EOF cat <<EOF
The parameters are currently just under 911MB in size, so plan accordingly The parameters are currently about 50MB, so plan accordingly
for your bandwidth constraints. If the files are already present and for your bandwidth constraints. If the files are already present and
have the correct sha256sum, no networking is used. have the correct sha256sum, no networking is used.
@@ -194,14 +193,9 @@ EOF
cd "$PARAMS_DIR" cd "$PARAMS_DIR"
# Sprout parameters:
fetch_params "$SPROUT_PKEY_NAME" "$PARAMS_DIR/$SPROUT_PKEY_NAME" "8bc20a7f013b2b58970cddd2e7ea028975c88ae7ceb9259a5344a16bc2c0eef7"
fetch_params "$SPROUT_VKEY_NAME" "$PARAMS_DIR/$SPROUT_VKEY_NAME" "4bd498dae0aacfd8e98dc306338d017d9c08dd0918ead18172bd0aec2fc5df82"
# Sapling parameters: # Sapling parameters:
fetch_params "$SAPLING_SPEND_NAME" "$PARAMS_DIR/$SAPLING_SPEND_NAME" "8e48ffd23abb3a5fd9c5589204f32d9c31285a04b78096ba40a79b75677efc13" fetch_params "$SAPLING_SPEND_NAME" "$PARAMS_DIR/$SAPLING_SPEND_NAME" "8e48ffd23abb3a5fd9c5589204f32d9c31285a04b78096ba40a79b75677efc13"
fetch_params "$SAPLING_OUTPUT_NAME" "$PARAMS_DIR/$SAPLING_OUTPUT_NAME" "2f0ebbcbb9bb0bcffe95a397e7eba89c29eb4dde6191c339db88570e3f3fb0e4" fetch_params "$SAPLING_OUTPUT_NAME" "$PARAMS_DIR/$SAPLING_OUTPUT_NAME" "2f0ebbcbb9bb0bcffe95a397e7eba89c29eb4dde6191c339db88570e3f3fb0e4"
fetch_params "$SAPLING_SPROUT_GROTH16_NAME" "$PARAMS_DIR/$SAPLING_SPROUT_GROTH16_NAME" "b685d700c60328498fbde589c8c7c484c722b788b265b72af448a5bf0ee55b50"
} }
main main