73 lines
1.6 KiB
Bash
Executable File
73 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
# link: https://git.p2p.legal/aya/dpgpid/
|
|
# desc: dpgpid (Decentralized PGP IDentifiers) shares PGP keys with DIDs on IPFS
|
|
|
|
# Copyleft 2022 Yann Autissier <aya@asycn.io>
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
set -eu
|
|
|
|
DATE=$(date -u +%FT%TZ%Z)
|
|
USAGE='[--help] [--version] list'
|
|
VERSION='0.0.1'
|
|
|
|
dpgpid() {
|
|
while test $# != 0; do
|
|
case "$1" in
|
|
-h|--help)
|
|
help
|
|
;;
|
|
-v|--version)
|
|
version
|
|
;;
|
|
--)
|
|
shift
|
|
break
|
|
;;
|
|
-*)
|
|
usage
|
|
;;
|
|
list)
|
|
list
|
|
;;
|
|
*)
|
|
break
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
}
|
|
|
|
help() {
|
|
usage
|
|
}
|
|
|
|
list() {
|
|
gpg --list-secret-keys --with-colons |awk -F: '$1 == "sec" {print $5}' |while read key; do
|
|
id=$(keygen -t ipfs -g ${key} 2>/dev/null) && printf "did:ipid:${id}\n" ||
|
|
echo "ERROR: Unable to extract id from key ${key}"
|
|
done
|
|
}
|
|
|
|
usage() {
|
|
printf "%s\n" "Usage: $(basename "$0") ${USAGE}"
|
|
}
|
|
|
|
version() {
|
|
printf "%s\n" "Version: $(basename "$0") v${VERSION}"
|
|
}
|
|
|
|
dpgpid "$@"
|