-
-
Save wiz/c4008ff485e9f773e81fb7b9471039e3 to your computer and use it in GitHub Desktop.
Bisq onion key sign/verify shell script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
FILE_TO_SIGN="$1" | |
PRIVATE_KEYFILE_PEM=$HOME/.local/share/Bisq/btc_mainnet/tor/hiddenservice/private_key | |
PUBLIC_KEYFILE_PEM=/tmp/pubkey.pem | |
PUBLIC_KEYFILE_DER=/tmp/pubkey.der | |
SIGNATURE_FILE=/tmp/signature | |
echo "public key in PEM:" | |
openssl rsa -in "${PRIVATE_KEYFILE_PEM}" -pubout -outform PEM -out "${PUBLIC_KEYFILE_PEM}" | |
openssl rsa -in "${PRIVATE_KEYFILE_PEM}" -pubout -outform DER -out "${PUBLIC_KEYFILE_DER}" | |
cat "${PUBLIC_KEYFILE_PEM}" | |
ONION=$(tail -c +23 "${PUBLIC_KEYFILE_DER}" | shasum -a 1 | head -c 20 | xxd -r -p | base32 | awk '{print tolower($0)}') | |
echo "onion hostname: ${ONION}" | |
echo "text to sign:" | |
cat "${FILE_TO_SIGN}" | |
echo "digest to sign:" | |
DIGEST=$(shasum -a 256 ${FILE_TO_SIGN} | awk '{print $1}') | |
echo "${DIGEST}" | |
echo "signature:" | |
openssl dgst -sha256 -sign "${PRIVATE_KEYFILE_PEM}" -keyform PEM "${FILE_TO_SIGN}" > "${SIGNATURE_FILE}" | |
base64 "${SIGNATURE_FILE}" | |
echo "verify" | |
openssl dgst -sha256 -verify "${PUBLIC_KEYFILE_PEM}" -keyform PEM -signature "${SIGNATURE_FILE}" "${FILE_TO_SIGN}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment