[zk] fetch-params.sh->fetch-zcash-params.sh, use ZCJoinSplit::Prepared to load pzcashParams

This commit is contained in:
Jon Layton 2018-07-11 16:42:17 -05:00
parent b5dc73d9ef
commit 7f245bb0f8
3 changed files with 16 additions and 17 deletions

View File

@ -242,7 +242,7 @@ cov: test_bitcoin.coverage/.dirstamp cov-zcash total.coverage/.dirstamp
endif
dist_bin_SCRIPTS = #zcutil/fetch-params.sh
dist_bin_SCRIPTS = scripts/fetch-zcash-params.sh
dist_noinst_SCRIPTS = autogen.sh
EXTRA_DIST = $(DIST_SHARE) test/functional/test_runner.py test/functional test/zcash $(DIST_CONTRIB) $(DIST_DOCS) $(WINDOWS_PACKAGING) $(OSX_PACKAGING) $(BIN_CHECKS)
@ -302,8 +302,6 @@ EXTRA_DIST += \
test/util/rpcauth-test.py
CLEANFILES = $(OSX_DMG) $(BITCOIN_WIN_INSTALLER)
install-exec-hook:
mv $(DESTDIR)$(bindir)/fetch-params.sh $(DESTDIR)$(bindir)/zcash-fetch-params
.INTERMEDIATE: $(COVERAGE_INFO)

View File

@ -85,7 +85,7 @@ EOF
function fetch_failure {
cat >&2 <<EOF
Failed to fetch the Zcash zkSNARK parameters!
Failed to fetch the Zcash/BTCP zkSNARK parameters!
Try installing one of the following programs and make sure you're online:
* ipfs
@ -146,20 +146,23 @@ function lock() {
}
function exit_locked_error {
echo "Only one instance of fetch-params.sh can be run at a time." >&2
echo "Only one instance of fetch-zcash-params.sh can be run at a time." >&2
exit 1
}
function main() {
lock fetch-params.sh \
lock fetch-zcash-params.sh \
|| exit_locked_error
cat <<EOF
Zcash - fetch-params.sh
Bitcoin Private - fetch-zcash-params.sh
Copyright (c) 2016-2018 The Zcash developers
This script will fetch the Zcash zkSNARK parameters and verify their
integrity with sha256sum.
This script will fetch the zkSNARK parameters from the Zcash ceremony
and verify their integrity with sha256sum. Bitcoin Private uses these
parameters the same way as in Zcash: to enable Zero-Knowledge proofs
that allow for shielded transactions to be constructed.
NOTE: If you're using testnet or regtest, you will need to invoke this
script with --testnet in order to download additional parameters. This
@ -174,7 +177,7 @@ EOF
mkdir -p "$PARAMS_DIR"
README_PATH="$PARAMS_DIR/README"
cat >> "$README_PATH" <<EOF
This directory stores common Zcash zkSNARK parameters. Note that it is
This directory stores Zcash/BTCP zkSNARK parameters. Note that it is
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.

View File

@ -60,6 +60,8 @@
#include <boost/thread.hpp>
#include <openssl/crypto.h>
#include <libsnark/common/profiling.hpp>
#if ENABLE_ZMQ
#include <zmq/zmqnotificationinterface.h>
#endif
@ -714,27 +716,23 @@ static void ZC_LoadParams()
if (!(boost::filesystem::exists(pk_path) && boost::filesystem::exists(vk_path))) {
uiInterface.ThreadSafeMessageBox(strprintf(
_("Cannot find the Bitcoin Private network parameters in the following directory:\n"
_("Cannot find the Zcash ceremony parameters for BTCP in the following directory:\n"
"%s\n"
"Please run 'zcash-fetch-params' or './btcputil/fetch-params.sh' and then restart."),
"Please run 'scripts/fetch-zcash-params.sh' and then restart."),
ZC_GetParamsDir()),
"", CClientUIInterface::MSG_ERROR);
StartShutdown();
return;
}
pzcashParams = ZCJoinSplit::Unopened();
LogPrintf("Loading verifying key from %s\n", vk_path.string().c_str());
gettimeofday(&tv_start, 0);
pzcashParams->loadVerifyingKey(vk_path.string());
pzcashParams = ZCJoinSplit::Prepared(vk_path.string(), pk_path.string());
gettimeofday(&tv_end, 0);
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);
pzcashParams->setProvingKeyPath(pk_path.string());
}
/** Sanity checks