Created
March 7, 2024 09:27
-
-
Save tommyv1987/e4e24495e2bdbbf5e34d35fcac4ed0e5 to your computer and use it in GitHub Desktop.
Provide a Signature using a Mixnode or Gateway
This file contains hidden or 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/bash | |
echo "do you want to sign a message with a mixnode or a gateway? enter 'mixnode' or 'gateway':" | |
read NODE_TYPE | |
case $NODE_TYPE in | |
mixnode) | |
NODE_TYPE="mixnode" | |
CONFIG_PATH_NODE="mixnodes" | |
;; | |
gateway) | |
NODE_TYPE="gateway" | |
CONFIG_PATH_NODE="gateways" | |
;; | |
*) | |
echo "invalid selection run either 'mixnode' or 'gateway'" | |
exit 1 | |
;; | |
esac | |
read -p "enter your home path (default is /home/nym): " USER_HOME_PATH | |
CONFIG_ROOT_PATH="${USER_HOME_PATH:-/home/nym}/.nym/${CONFIG_PATH_NODE}/*/config" | |
NODE_ID=$(grep '^id =' $CONFIG_ROOT_PATH/config.toml | awk -F"'" '{print $2}') | |
LISTENING_ADDRESS=$(grep 'listening_address =' $CONFIG_ROOT_PATH/config.toml | awk -F"'" '{print $2}') | |
if [[ -z "$NODE_ID" || -z "$LISTENING_ADDRESS" ]]; then | |
echo "failed to extract node id or listening address using ${NODE_TYPE}, do you have the correct node selected? 🧐 " | |
exit 1 | |
fi | |
read -p "enter the text you want to sign (default is your listening address): " TEXT_TO_SIGN | |
TEXT_TO_SIGN="${TEXT_TO_SIGN:-$LISTENING_ADDRESS}" | |
SIGNATURE_OUTPUT=$(./nym-${NODE_TYPE} sign --id "$NODE_ID" --text "$TEXT_TO_SIGN" --output json 2>/dev/null) | |
ENCODED_MESSAGE=$(echo "$SIGNATURE_OUTPUT" | jq -r '.encoded_message') | |
ENCODED_SIGNATURE=$(echo "$SIGNATURE_OUTPUT" | jq -r '.encoded_signature') | |
echo "encoded message: $ENCODED_MESSAGE" | |
echo "encoded bs58 sig: $ENCODED_SIGNATURE" | |
echo "node id: $NODE_ID" | |
echo "text signed: $TEXT_TO_SIGN" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
output is as follows:
The examples above have been slightly modified to show case the output.