https://gitlab.com/tezos/tezos
Raw File
Tip revision: a09d288301dcc7ffc7dc1d6672ce188e8d010484 authored by Alain Mebsout on 24 April 2023, 09:01:28 UTC
TMP: doc
Tip revision: a09d288
install_sapling_parameters.sh
#!/usr/bin/env bash

set -e

script_dir="$(cd "$(dirname "$0")" && pwd -P)"

#shellcheck source=scripts/version.sh
. "$script_dir"/version.sh

# Install Sapling parameters.
ZCASH_PARAMS="${OPAM_SWITCH_PREFIX}/share/zcash-params"
OUTPUT_PARAMETERS_URL="${opam_repository_url}/-/raw/${opam_repository_tag}/zcash-params/sapling-output.params"
OUTPUT_PARAMETERS_FILE=${ZCASH_PARAMS}/sapling-output.params
SPEND_PARAMETERS_URL="${opam_repository_url}/-/raw/${opam_repository_tag}/zcash-params/sapling-spend.params"
SPEND_PARAMETERS_FILE=${ZCASH_PARAMS}/sapling-spend.params

echo "Installing Sapling parameters in ${ZCASH_PARAMS}"
mkdir -p "${ZCASH_PARAMS}"

if type sha256sum ; then
    SHASUM=sha256sum
elif type shasum ; then
    SHASUM="shasum -a 256"
else
    echo "Utility to compute SHA2-256 digest is not found, tried sha256sum and shasum"
    exit 1
fi
echo "Using ${SHASUM}"

if ! echo "${sapling_output_parameters_sha256}  ${OUTPUT_PARAMETERS_FILE}" | ${SHASUM} --check  > /dev/null 2>&1 ; then
    echo "Downloading ${OUTPUT_PARAMETERS_URL}..."
    rm -f "${OUTPUT_PARAMETERS_FILE}"
    curl -s -o "${OUTPUT_PARAMETERS_FILE}" "${OUTPUT_PARAMETERS_URL}"
    if ! echo "${sapling_output_parameters_sha256}  ${OUTPUT_PARAMETERS_FILE}" | ${SHASUM} --check  > /dev/null 2>&1 ; then
        echo "Unexpected sha256 for ${OUTPUT_PARAMETERS_FILE}."
        exit 1
    fi
else
    echo "File 'sapling-output.params' is already installed."
fi

if ! echo "${sapling_spend_parameters_sha256}  ${SPEND_PARAMETERS_FILE}" | ${SHASUM} --check  > /dev/null 2>&1 ; then
    echo "Downloading ${SPEND_PARAMETERS_URL}..."
    rm -f "${SPEND_PARAMETERS_FILE}"
    curl -s -o "${SPEND_PARAMETERS_FILE}" "${SPEND_PARAMETERS_URL}"
    if ! echo "${sapling_spend_parameters_sha256}  ${SPEND_PARAMETERS_FILE}" | ${SHASUM} --check  > /dev/null 2>&1 ; then
        echo "Unexpected sha256 for ${SPEND_PARAMETERS_FILE}."
        exit 1
    fi
else
    echo "File 'sapling-spend.params' is already installed."
fi
back to top