Auto merge of #1476 - ebfull:update-parameters, r=str4d

Update to beta2 public parameters

Also gets rid of the `testnet3`/`regtest` subdirectories/symlinks and other such things.
This commit is contained in:
zkbot 2016-10-04 04:54:02 -04:00
commit d86218a52f
4 changed files with 23 additions and 37 deletions

View File

@ -613,8 +613,8 @@ static void ZC_LoadParams()
struct timeval tv_start, tv_end;
float elapsed;
boost::filesystem::path pk_path = ZC_GetParamsDir() / "z9-proving.key";
boost::filesystem::path vk_path = ZC_GetParamsDir() / "z9-verifying.key";
boost::filesystem::path pk_path = ZC_GetParamsDir() / "beta2-proving.key";
boost::filesystem::path vk_path = ZC_GetParamsDir() / "beta2-verifying.key";
pzcashParams = ZCJoinSplit::Unopened();

View File

@ -478,7 +478,6 @@ const boost::filesystem::path &ZC_GetParamsDir()
return path;
path = ZC_GetBaseParamsDir();
path /= BaseParams().DataDir();
return path;
}

View File

@ -52,8 +52,8 @@ double benchmark_sleep()
double benchmark_parameter_loading()
{
// FIXME: this is duplicated with the actual loading code
boost::filesystem::path pk_path = ZC_GetParamsDir() / "z9-proving.key";
boost::filesystem::path vk_path = ZC_GetParamsDir() / "z9-verifying.key";
boost::filesystem::path pk_path = ZC_GetParamsDir() / "beta2-proving.key";
boost::filesystem::path vk_path = ZC_GetParamsDir() / "beta2-verifying.key";
struct timeval tv_start;
timer_start(tv_start);

View File

@ -4,19 +4,16 @@ set -eu
PARAMS_DIR="$HOME/.zcash-params"
REGTEST_PKEY_NAME='z9-proving.key'
REGTEST_VKEY_NAME='z9-verifying.key'
REGTEST_PKEY_URL="https://z.cash/downloads/$REGTEST_PKEY_NAME"
REGTEST_VKEY_URL="https://z.cash/downloads/$REGTEST_VKEY_NAME"
REGTEST_DIR="$PARAMS_DIR/regtest"
# This should have the same params as regtest. We use symlinks for now.
TESTNET3_DIR="$PARAMS_DIR/testnet3"
BETA2_PKEY_NAME='beta2-proving.key'
BETA2_VKEY_NAME='beta2-verifying.key'
BETA2_PKEY_URL="https://z.cash/downloads/$BETA2_PKEY_NAME"
BETA2_VKEY_URL="https://z.cash/downloads/$BETA2_VKEY_NAME"
function fetch_params {
local url="$1"
local output="$2"
local dlname="${output}.dl"
local expectedhash="$3"
if ! [ -f "$output" ]
then
@ -27,8 +24,18 @@ function fetch_params {
--continue \
"$url"
# Only after successful download do we update the parameter load path:
mv -v "$dlname" "$output"
shasum -a 256 --check <<EOF
$expectedhash $dlname
EOF
# Check the exit code of the shasum command:
CHECKSUM_RESULT=$?
if [ $CHECKSUM_RESULT -eq 0 ]; then
mv -v "$dlname" "$output"
else
echo "Failed to verify parameter checksums!"
exit 1
fi
fi
}
@ -86,30 +93,10 @@ $README_PATH
EOF
fi
mkdir -p "$REGTEST_DIR"
fetch_params "$REGTEST_PKEY_URL" "$REGTEST_DIR/$REGTEST_PKEY_NAME"
fetch_params "$REGTEST_VKEY_URL" "$REGTEST_DIR/$REGTEST_VKEY_NAME"
cd "$PARAMS_DIR"
# Now verify their hashes:
echo 'Verifying parameter file integrity via sha256sum...'
shasum -a 256 --check <<EOF
226913bbdc48b70834f8e044d194ddb61c8e15329f67cdc6014f4e5ac11a82ab regtest/$REGTEST_PKEY_NAME
4c151c562fce2cdee55ac0a0f8bd9454eb69e6a0db9a8443b58b770ec29b37f5 regtest/$REGTEST_VKEY_NAME
EOF
# Check the exit code of the shasum command:
CHECKSUM_RESULT=$?
if [ $CHECKSUM_RESULT -eq 0 ]; then
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"
else
exit 1
fi
fetch_params "$BETA2_PKEY_URL" "$PARAMS_DIR/$BETA2_PKEY_NAME" "cca9887becf803c8ca801bc9da8fcba4f5fb3ba13af9d17e8603021a150cb4b7"
fetch_params "$BETA2_VKEY_URL" "$PARAMS_DIR/$BETA2_VKEY_NAME" "2faffd2a5e2e67276c3471c48068a0c16f62286d2e4622a733d7cd1f82ffa860"
}
main