2015-12-15 00:26:04 -08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
PARAMS_DIR="$HOME/.zcash-params"
|
|
|
|
|
2016-08-18 12:17:55 -07:00
|
|
|
REGTEST_PKEY_NAME='z9-proving.key'
|
|
|
|
REGTEST_VKEY_NAME='z9-verifying.key'
|
2016-01-19 08:17:04 -08:00
|
|
|
REGTEST_PKEY_URL="https://z.cash/downloads/$REGTEST_PKEY_NAME"
|
|
|
|
REGTEST_VKEY_URL="https://z.cash/downloads/$REGTEST_VKEY_NAME"
|
2015-12-15 00:26:04 -08:00
|
|
|
REGTEST_DIR="$PARAMS_DIR/regtest"
|
|
|
|
|
2016-01-19 08:17:04 -08:00
|
|
|
# This should have the same params as regtest. We use symlinks for now.
|
|
|
|
TESTNET3_DIR="$PARAMS_DIR/testnet3"
|
|
|
|
|
2015-12-15 00:26:04 -08:00
|
|
|
|
|
|
|
function fetch_params {
|
|
|
|
local url="$1"
|
2016-01-28 13:38:30 -08:00
|
|
|
local output="$2"
|
|
|
|
local dlname="${output}.dl"
|
2016-01-22 09:37:24 -08:00
|
|
|
|
2016-01-28 13:38:30 -08:00
|
|
|
if ! [ -f "$output" ]
|
2015-12-15 00:26:04 -08:00
|
|
|
then
|
|
|
|
echo "Retrieving: $url"
|
2016-01-20 14:45:18 -08:00
|
|
|
# Note: --no-check-certificate should be ok, since we rely on
|
|
|
|
# sha256 for integrity, and there's no confidentiality requirement.
|
|
|
|
# Our website uses letsencrypt certificates which are not supported
|
|
|
|
# by some wget installations, so we expect some cert failures.
|
|
|
|
wget \
|
|
|
|
--progress=dot:giga \
|
|
|
|
--no-check-certificate \
|
2016-01-22 09:37:24 -08:00
|
|
|
--output-document="$dlname" \
|
|
|
|
--continue \
|
2016-01-20 14:45:18 -08:00
|
|
|
"$url"
|
2016-01-22 09:37:24 -08:00
|
|
|
|
|
|
|
# Only after successful download do we update the parameter load path:
|
2016-01-28 13:38:30 -08:00
|
|
|
mv -v "$dlname" "$output"
|
2015-12-15 00:26:04 -08:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
cat <<EOF
|
|
|
|
zcash - fetch-params.sh
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# Now create PARAMS_DIR and insert a README if necessary:
|
|
|
|
if ! [ -d "$PARAMS_DIR" ]
|
|
|
|
then
|
|
|
|
mkdir -p "$PARAMS_DIR"
|
|
|
|
README_PATH="$PARAMS_DIR/README"
|
|
|
|
cat >> "$README_PATH" <<EOF
|
2016-09-15 04:58:55 -07:00
|
|
|
This directory stores common zcash zkSNARK parameters. Note that it is
|
2015-12-15 00:26:04 -08:00
|
|
|
distinct from the daemon's -datadir argument because the parameters are
|
|
|
|
large and may be shared across multiple distinct -datadir's such as when
|
|
|
|
setting up test networks.
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# This may be the first time the user's run this script, so give
|
|
|
|
# them some info, especially about bandwidth usage:
|
|
|
|
cat <<EOF
|
2015-12-21 23:49:17 -08:00
|
|
|
This script will fetch the Zcash zkSNARK parameters and verify their
|
2015-12-15 00:26:04 -08:00
|
|
|
integrity with sha256sum.
|
|
|
|
|
2016-09-15 05:00:13 -07:00
|
|
|
The parameters are currently just under 911MB in size, so plan accordingly
|
2015-12-15 00:26:04 -08:00
|
|
|
for your bandwidth constraints. If the files are already present and
|
|
|
|
have the correct sha256sum, no networking is used.
|
|
|
|
|
|
|
|
Creating params directory. For details about this directory, see:
|
|
|
|
$README_PATH
|
|
|
|
|
|
|
|
EOF
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p "$REGTEST_DIR"
|
|
|
|
|
2016-01-28 13:38:30 -08:00
|
|
|
fetch_params "$REGTEST_PKEY_URL" "$REGTEST_DIR/$REGTEST_PKEY_NAME"
|
|
|
|
fetch_params "$REGTEST_VKEY_URL" "$REGTEST_DIR/$REGTEST_VKEY_NAME"
|
2016-01-19 08:17:04 -08:00
|
|
|
|
|
|
|
echo 'Updating testnet3 symlinks to regtest parameters.'
|
|
|
|
mkdir -p "$TESTNET3_DIR"
|
|
|
|
ln -sf "../regtest/$REGTEST_PKEY_NAME" "$TESTNET3_DIR/$REGTEST_PKEY_NAME"
|
|
|
|
ln -sf "../regtest/$REGTEST_VKEY_NAME" "$TESTNET3_DIR/$REGTEST_VKEY_NAME"
|
|
|
|
|
2016-01-28 13:38:30 -08:00
|
|
|
cd "$PARAMS_DIR"
|
|
|
|
|
2015-12-15 00:26:04 -08:00
|
|
|
# Now verify their hashes:
|
|
|
|
echo 'Verifying parameter file integrity via sha256sum...'
|
2016-05-23 01:30:09 -07:00
|
|
|
shasum -a 256 --check <<EOF
|
2016-08-18 12:17:55 -07:00
|
|
|
226913bbdc48b70834f8e044d194ddb61c8e15329f67cdc6014f4e5ac11a82ab regtest/$REGTEST_PKEY_NAME
|
|
|
|
226913bbdc48b70834f8e044d194ddb61c8e15329f67cdc6014f4e5ac11a82ab testnet3/$REGTEST_PKEY_NAME
|
|
|
|
4c151c562fce2cdee55ac0a0f8bd9454eb69e6a0db9a8443b58b770ec29b37f5 regtest/$REGTEST_VKEY_NAME
|
|
|
|
4c151c562fce2cdee55ac0a0f8bd9454eb69e6a0db9a8443b58b770ec29b37f5 testnet3/$REGTEST_VKEY_NAME
|
2015-12-15 00:26:04 -08:00
|
|
|
EOF
|
2016-01-19 08:17:04 -08:00
|
|
|
|