dunikey2secret.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. ########################################################################
  3. # Author: Fred (support@qo-op.com)
  4. # Version: 1.0
  5. # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
  6. ########################################################################
  7. # This script convert secret.dunikey into ~/.ssb/secret.ssb
  8. ########################################################################
  9. MY_PATH="`dirname \"$0\"`" # relative
  10. MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
  11. ########################################################################
  12. # \\///
  13. # qo-op
  14. #############
  15. DUNIKEYFILE="$1"
  16. [[ ! ${DUNIKEYFILE} ]] && DUNIKEYFILE="/tmp/secret.dunikey"
  17. [[ ! ${DUNIKEYFILE} ]] && DUNIKEYFILE="~/.ssb/secret.dunikey"
  18. [[ ! -f ${DUNIKEYFILE} ]] && echo "ERROR secret.dunikey unfound" && exit 1
  19. pub=$(cat ${DUNIKEYFILE} | grep "pub" | cut -d ' ' -f 2)
  20. priv=$(cat ${DUNIKEYFILE} | grep "sec" | cut -d ' ' -f 2)
  21. ssbpub=$(echo $pub | base58 -d | base64)
  22. ssbpriv=$(echo $priv | base58 -d | base64 | tr -d "\n")
  23. cat > /tmp/secret.ssb <<EOF
  24. # This secret generated by duniter2secret.sh
  25. # G1 Wallet ACCOUNT BALANCE:
  26. # silkaj balance $pub
  27. #
  28. # THIS KEY IS YOURS!
  29. # NEVER show this to anyone!!!
  30. {
  31. "curve": "ed25519",
  32. "public": "$ssbpub.ed25519",
  33. "private": "$ssbpriv.ed25519",
  34. "id": "@$ssbpub.ed25519"
  35. }
  36. EOF
  37. echo 'Your key is located in /tmp/secret.ssb'
  38. exit 0