From 7b539afbdd8847f8e3d6e2aa4636d9410c9398f3 Mon Sep 17 00:00:00 2001 From: Yann Autissier Date: Mon, 12 Sep 2022 14:19:05 +0200 Subject: [PATCH] update default behaviour to show only public key * bump version v0.0.2 --- keygen | 155 +++++++++++++++++++++++-------------------- specs/keygen_spec.sh | 127 +++++++++++++++++++++++++++-------- 2 files changed, 183 insertions(+), 99 deletions(-) diff --git a/keygen b/keygen index 31818f9..1a06261 100755 --- a/keygen +++ b/keygen @@ -45,17 +45,26 @@ import sys import time import warnings -__version__='0.0.1' +__version__='0.0.2' class keygen: def __init__(self): - self.parser = argparse.ArgumentParser() +# desc: generate ed25519 keys suitable for duniter or ipfs + self.parser = argparse.ArgumentParser(description=""" + Generate ed25519 keys. It converts your Duniter username and password or + a GPG key to an IPFS PeerID.""") self.parser.add_argument( "-d", "--debug", action="store_true", help="show debug informations (WARNING: including SECRET KEY value)", ) + self.parser.add_argument( + "-g", + "--gpg", + action="store_true", + help="use gpg key from user id matched by username option as input", + ) self.parser.add_argument( "-i", "--input", @@ -64,10 +73,10 @@ class keygen: help="read public and secret keys in pubsec format from file INPUT", ) self.parser.add_argument( - "-g", - "--gpg", + "-k", + "--keys", action="store_true", - help="use gpg key from user id matched by username option as input", + help="show public and secret keys", ) self.parser.add_argument( "-o", @@ -78,9 +87,9 @@ class keygen: ) self.parser.add_argument( "-p", - "--public", + "--prefix", action="store_true", - help="show only public key", + help="prefix key with key type", ) self.parser.add_argument( "-q", @@ -92,7 +101,7 @@ class keygen: "-s", "--secret", action="store_true", - help="show only secret key", + help="show secret key", ) self.parser.add_argument( "-t", @@ -130,33 +139,44 @@ class keygen: def _cleanup(self): log.debug("keygen._cleanup()") - if hasattr(self, 'armored_pgp_secret_key'): + if hasattr(self, 'armored_pgp_secret_key') and self.armored_pgp_secret_key: clearmem(self.armored_pgp_secret_key) - if hasattr(self, 'base58_secret_key'): + log.debug("cleared: keygen.armored_pgp_secret_key") + if hasattr(self, 'base58_secret_key') and self.base58_secret_key: clearmem(self.base58_secret_key) + log.debug("cleared: keygen.base58_secret_key") if hasattr(self, 'duniter'): - if hasattr(self.duniter, 'sk'): + if hasattr(self.duniter, 'sk') and self.duniterpy.sk: clearmem(self.duniterpy.sk) - if hasattr(self, 'ed25519_secret_bytes'): + log.debug("cleared: keygen.duniterpy.sk") + if hasattr(self, 'ed25519_secret_bytes') and self.ed25519_secret_bytes: clearmem(self.ed25519_secret_bytes) - if hasattr(self, 'ed25519_secret_pem_pkcs8'): + log.debug("cleared: keygen.ed25519_secret_bytes") + if hasattr(self, 'ed25519_secret_pem_pkcs8') and self.ed25519_secret_pem_pkcs8: clearmem(self.ed25519_secret_pem_pkcs8) - if hasattr(self, 'ipfs_privkey'): + log.debug("cleared: keygen.ed25515_secret_pem_pkcs8") + if hasattr(self, 'ipfs_privkey') and self.ipfs_privkey: clearmem(self.ipfs_privkey) - if hasattr(self, 'password'): - if self.password: - clearmem(self.password) + log.debug("cleared: keygen.ipfs_privkey") + if hasattr(self, 'password') and self.password: + clearmem(self.password) + log.debug("cleared: keygen.password") if hasattr(self, 'pgpy'): - if hasattr(self.pgpy._key.keymaterial, 'p') and not isinstance(self.pgpy._key.keymaterial.p, object): + if hasattr(self.pgpy._key.keymaterial, 'p') and self.pgpy._key.keymaterial.p and not isinstance(self.pgpy._key.keymaterial.p, pgpy.packet.fields.ECPoint): clearmem(self.pgpy._key.keymaterial.p) - if hasattr(self.pgpy._key.keymaterial, 'q'): + log.debug("cleared: keygen.pgpy._key.material.p") + if hasattr(self.pgpy._key.keymaterial, 'q') and self.pgpy._key.keymaterial.q: clearmem(self.pgpy._key.keymaterial.q) - if hasattr(self.pgpy._key.keymaterial, 's'): + log.debug("cleared: keygen.pgpy._key.material.q") + if hasattr(self.pgpy._key.keymaterial, 's') and self.pgpy._key.keymaterial.s: clearmem(self.pgpy._key.keymaterial.s) - if hasattr(self, 'pgpy_key_seed'): - clearmem(self.pgpy_key_seed) - if hasattr(self, 'pgpy_key_value'): - clearmem(self.pgpy_key_value) + log.debug("cleared: keygen.pgpy._key.material.s") + if hasattr(self, 'pgp_key_seed') and self.pgp_key_seed: + clearmem(self.pgp_key_seed) + log.debug("cleared: keygen.pgp_key_seed") + if hasattr(self, 'pgp_key_value') and self.pgp_key_value: + clearmem(self.pgp_key_value) + log.debug("cleared: keygen.pgp_key_value") def _invalid_type(self): log.debug("keygen._invalid_type()") @@ -219,14 +239,10 @@ class keygen: log.debug("keygen.do_duniter()") self.base58_from_ed25519() if self.output is None: - if not self.public and not self.secret: - print("pub: %s" % self.base58_public_key) - print("sec: %s" % self.base58_secret_key) - else: - if self.public: - print(self.base58_public_key) - if self.secret: - print(self.base58_secret_key) + if self.keys or not self.secret: + print("%s" % ''.join([self.prefix * 'pub: ', self.base58_public_key])) + if self.keys or self.secret: + print("%s" % ''.join([self.prefix * 'sec: ', self.base58_secret_key])) else: with open(self.output, "w") as fh: fh.write(f"""Type: PubSec @@ -245,14 +261,10 @@ sec: {self.base58_secret_key} log.debug("keygen.do_ipfs()") self.ipfs_from_ed25519() if self.output is None: - if not self.public and not self.secret: - print("PeerID: %s" % self.ipfs_peerid) - print("PrivKEY: %s" % self.ipfs_privkey) - else: - if self.public: - print(self.ipfs_peerid) - if self.secret: - print(self.ipfs_privkey) + if self.keys or not self.secret: + print("%s" % ''.join(['PeerID: ' * self.prefix, self.ipfs_peerid])) + if self.keys or self.secret: + print("%s" % ''.join(['PrivKEY: ' * self.prefix, self.ipfs_privkey])) else: # with open(self.output, "wb") as fh: # fh.write(self.ipfs_libp2p_protobuf_key) @@ -277,6 +289,7 @@ sec: {self.base58_secret_key} self.password = p.get_pin() except pynentry.PinEntryCancelled: log.warning('Cancelled! Goodbye.') + self._cleanup() exit(2) self.duniterpy = duniterpy.key.SigningKey.from_credentials( self.username, @@ -315,12 +328,17 @@ sec: {self.base58_secret_key} log.debug("keygen.gpg_seckeys=%s" % self.gpg_seckeys) if not self.gpg_seckeys: log.error(f"""Unable to find any key matching username "{self.username}".""") + self._cleanup() exit(1) else: self.gpg_seckey = self.gpg_seckeys[0] log.info(f"""Found key id "{self.gpg_seckey.fpr}" matching username "{self.username}".""") - log.debug("keygen.gpg_seckey.__repr__=%s" % self.gpg_seckey.__repr__) + log.debug("keygen.gpg_seckey.expired=%s" % self.gpg_seckey.expired) log.debug("keygen.gpg_seckey.fpr=%s" % self.gpg_seckey.fpr) + log.debug("keygen.gpg_seckey.revoked=%s" % self.gpg_seckey.revoked) + log.debug("keygen.gpg_seckey.uids=%s" % self.gpg_seckey.uids) + log.debug("keygen.gpg_seckey.owner_trust=%s" % self.gpg_seckey.owner_trust) + log.debug("keygen.gpg_seckey.last_update=%s" % self.gpg_seckey.last_update) self.armored_pgp_public_key = self.gpg.key_export(self.gpg_seckey.fpr) log.debug("keygen.armored_pgp_public_key=%s" % self.armored_pgp_public_key) if self.password: @@ -328,7 +346,8 @@ sec: {self.base58_secret_key} self.armored_pgp_secret_key = self.gpg.key_export_secret(self.gpg_seckey.fpr) log.debug("keygen.armored_pgp_secret_key=%s" % self.armored_pgp_secret_key) if not self.armored_pgp_secret_key: - log.error(f"""Unable to export secret key id "{self.gpg_seckey.fpr}" of user "{self.username}". Please check your password!""") + log.error(f"""Unable to export gpg secret key id "{self.gpg_seckey.fpr}" of user "{self.username}". Please check your password!""") + self._cleanup() exit(2) with warnings.catch_warnings(): # remove CryptographyDeprecationWarning about deprecated @@ -344,7 +363,7 @@ sec: {self.base58_secret_key} if self.pgpy.is_protected: if not self.password: with pynentry.PynEntry() as p: - p.description = f"""The exported key id "{self.pgpy.fingerprint.keyid}" of user "{self.username}" is password protected. + p.description = f"""The exported pgp key id "{self.pgpy.fingerprint.keyid}" of user "{self.username}" is password protected. Please enter the passphrase again to unlock it. """ p.prompt = 'Passphrase:' @@ -352,6 +371,7 @@ sec: {self.base58_secret_key} self.password = p.get_pin() except pynentry.PinEntryCancelled: log.warning('Cancelled! Goodbye.') + self._cleanup() exit(2) try: with warnings.catch_warnings(): @@ -361,13 +381,14 @@ sec: {self.base58_secret_key} with self.pgpy.unlock(self.password): assert self.pgpy.is_unlocked log.debug("keygen.pgpy.is_unlocked=%s" % self.pgpy.is_unlocked) - self.pgpy_key_seed_from_pgpy() + self.pgp_key_seed_from_pgpy() except Exception as e: - log.error(f"""Unable to unlock secret key id "{self.gpg_seckey.fpr}" of user "{self.username}". Please check your password!""") + log.error(f"""Unable to unlock pgp secret key id "{self.pgpy.fingerprint.keyid}" of user "{self.username}". Please check your password!""") + self._cleanup() exit(2) else: - self.pgpy_key_seed_from_pgpy() - self.ed25519_public_bytes, self.ed25519_secret_bytes = nacl.bindings.crypto_sign_seed_keypair(self.pgpy_key_seed) + self.pgp_key_seed_from_pgpy() + self.ed25519_public_bytes, self.ed25519_secret_bytes = nacl.bindings.crypto_sign_seed_keypair(self.pgp_key_seed) log.debug("keygen.ed25519_public_bytes=%s" % self.ed25519_public_bytes) log.debug("keygen.ed25519_secret_bytes=%s" % self.ed25519_secret_bytes) @@ -402,41 +423,29 @@ sec: {self.base58_secret_key} self.ed25519_secret_pem_pkcs8 = ed25519.Ed25519PrivateKey.from_private_bytes(self.ed25519_secret_bytes[:32]).private_bytes(encoding=serialization.Encoding.PEM, format=serialization.PrivateFormat.PKCS8, encryption_algorithm=serialization.NoEncryption()).decode('ascii') log.debug("keygen.ed25519_secret_pem_pkcs8=%s" % self.ed25519_secret_pem_pkcs8) - def pgpy_key_flags(self): - log.debug("keygen.pgpy_key_flags()") - flags = [] - strs = {pgpy.constants.KeyFlags.Certify : 'C', - pgpy.constants.KeyFlags.Sign : 'S', - pgpy.constants.KeyFlags.EncryptCommunications : 'E', - pgpy.constants.KeyFlags.Authentication : 'A'} - for sig in self.pgpy.self_signatures: - if not sig.is_expired: - flags += sig.key_flags - self.pgpy_key_flags = "".join(strs.get(flag, '') for flag in flags) - - def pgpy_key_seed_from_pgpy(self): - log.debug("keygen.pgpy_key_seed_from_pgpy()") + def pgp_key_seed_from_pgpy(self): + log.debug("keygen.pgp_key_seed_from_pgpy()") self.pgpy_key_type() if self.pgpy_key_type == 'RSA': log.debug("keygen.pgpy._key.keymaterial.p=%s" % self.pgpy._key.keymaterial.p) log.debug("keygen.pgpy._key.keymaterial.q=%s" % self.pgpy._key.keymaterial.q) # custom seed: use sha256 hash of (p + q) - self.pgpy_key_seed = nacl.bindings.crypto_hash_sha256(long_to_bytes(self.pgpy._key.keymaterial.p + self.pgpy._key.keymaterial.q)) + self.pgp_key_seed = nacl.bindings.crypto_hash_sha256(long_to_bytes(self.pgpy._key.keymaterial.p + self.pgpy._key.keymaterial.q)) p = long_to_bytes(self.pgpy._key.keymaterial.p) q = long_to_bytes(self.pgpy._key.keymaterial.q) - self.pgpy_key_value = "".join([f"{c:02x}" for c in p]) + "".join([f"{c:02x}" for c in q]) - self.pgpy_key_size = (len(p) + len(q)) * 8 - log.debug("keygen.pgpy_key_seed=%s" % self.pgpy_key_seed) - log.debug("keygen.pgpy_key_value=%s" % self.pgpy_key_value) - log.debug("keygen.pgpy_key_size=%s" % self.pgpy_key_size) + self.pgp_key_value = "".join([f"{c:02x}" for c in p]) + "".join([f"{c:02x}" for c in q]) + self.pgp_key_size = (len(p) + len(q)) * 8 + log.debug("keygen.pgp_key_seed=%s" % self.pgp_key_seed) + log.debug("keygen.pgp_key_value=%s" % self.pgp_key_value) + log.debug("keygen.pgp_key_size=%s" % self.pgp_key_size) elif self.pgpy_key_type in ('ECDSA', 'EdDSA', 'ECDH'): log.debug("keygen.pgpy._key.keymaterial.s=%s" % self.pgpy._key.keymaterial.s) - self.pgpy_key_seed = long_to_bytes(self.pgpy._key.keymaterial.s) - self.pgpy_key_value = "".join([f"{c:02x}" for c in self.pgpy_key_seed]) - self.pgpy_key_size = len(self.pgpy_key_seed)*8 - log.debug("keygen.pgpy_key_seed=%s" % self.pgpy_key_seed) - log.debug("keygen.pgpy_key_value=%s" % self.pgpy_key_value) - log.debug("keygen.pgpy_key_size=%s" % self.pgpy_key_size) + self.pgp_key_seed = long_to_bytes(self.pgpy._key.keymaterial.s) + self.pgp_key_value = "".join([f"{c:02x}" for c in self.pgp_key_seed]) + self.pgp_key_size = len(self.pgp_key_seed)*8 + log.debug("keygen.pgp_key_seed=%s" % self.pgp_key_seed) + log.debug("keygen.pgp_key_value=%s" % self.pgp_key_value) + log.debug("keygen.pgp_key_size=%s" % self.pgp_key_size) else: raise NotImplementedError(f"Getting seed from {self.pgpy_key_type} key is not implemented") diff --git a/specs/keygen_spec.sh b/specs/keygen_spec.sh index 562b9e4..b4546c4 100644 --- a/specs/keygen_spec.sh +++ b/specs/keygen_spec.sh @@ -50,14 +50,64 @@ Describe 'keygen' Describe '--version:' It 'prints version' When run keygen --version - The output should include 'v0.0.1' + The output should include 'v0.0.2' The status should be success The stderr should equal "" End End - Describe '-t duniter username password:' - It 'prints duniter keys for user username' - When run keygen -t duniter username password + Describe 'username password:' + It 'prints base58 public key for user "username" with password "password"' + When run keygen username password + The output should include '4YLU1xQ9jzb7LzC6d91VZrYTEKS9N2j93Nnvcee6wxZG' + The status should be success + The stderr should equal "" + End + End + Describe '-p username password:' + It 'prints prefixed base58 public key for user "username" with password "password"' + When run keygen -p username password + The output should include 'pub: 4YLU1xQ9jzb7LzC6d91VZrYTEKS9N2j93Nnvcee6wxZG' + The status should be success + The stderr should equal "" + End + End + Describe '-s username password:' + It 'prints base58 secret key for user "username" with password "password"' + When run keygen -s username password + The output should include 'K5heSX4xGUPtRbxcZh6zbgaKbDv8FeVc9JuSNWtUs7C1oGNKqv7kQJ3DHdouTPzoW4duKKnuLQK8LbHKfN9fkjC' + The status should be success + The stderr should equal "" + End + End + Describe '-ps username password:' + It 'prints prefixed base58 secret key for user "username" with password "password"' + When run keygen -ps username password + The output should include 'sec: K5heSX4xGUPtRbxcZh6zbgaKbDv8FeVc9JuSNWtUs7C1oGNKqv7kQJ3DHdouTPzoW4duKKnuLQK8LbHKfN9fkjC' + The status should be success + The stderr should equal "" + End + End + Describe '-k username password:' + It 'prints base58 public and secret keys for user "username" with password "password"' + When run keygen -k username password + The output should include '4YLU1xQ9jzb7LzC6d91VZrYTEKS9N2j93Nnvcee6wxZG' + The output should include 'K5heSX4xGUPtRbxcZh6zbgaKbDv8FeVc9JuSNWtUs7C1oGNKqv7kQJ3DHdouTPzoW4duKKnuLQK8LbHKfN9fkjC' + The status should be success + The stderr should equal "" + End + End + Describe '-pk username password:' + It 'prints prefixed base58 public and secret keys for user "username" with password "password"' + When run keygen -pk username password + The output should include 'pub: 4YLU1xQ9jzb7LzC6d91VZrYTEKS9N2j93Nnvcee6wxZG' + The output should include 'sec: K5heSX4xGUPtRbxcZh6zbgaKbDv8FeVc9JuSNWtUs7C1oGNKqv7kQJ3DHdouTPzoW4duKKnuLQK8LbHKfN9fkjC' + The status should be success + The stderr should equal "" + End + End + Describe '-t duniter -pk username password:' + It 'prints prefixed duniter public key for user "username" with password "password"' + When run keygen -t duniter -pk username password The output should include 'pub: 4YLU1xQ9jzb7LzC6d91VZrYTEKS9N2j93Nnvcee6wxZG' The output should include 'sec: K5heSX4xGUPtRbxcZh6zbgaKbDv8FeVc9JuSNWtUs7C1oGNKqv7kQJ3DHdouTPzoW4duKKnuLQK8LbHKfN9fkjC' The status should be success @@ -66,7 +116,7 @@ Describe 'keygen' End Describe "-o ${DUNITER_PUBSEC_FILE} -t duniter username password:" rm -f "${DUNITER_PUBSEC_FILE}" - It 'writes duniter keys to file for user username' + It 'writes duniter keys to file for user "username" with password "password"' When run keygen -o "${DUNITER_PUBSEC_FILE}" -t duniter username password The path "${DUNITER_PUBSEC_FILE}" should exist The contents of file "${DUNITER_PUBSEC_FILE}" should include 'pub: 4YLU1xQ9jzb7LzC6d91VZrYTEKS9N2j93Nnvcee6wxZG' @@ -75,9 +125,9 @@ Describe 'keygen' The stderr should equal "" End End - Describe "-i ${DUNITER_PUBSEC_FILE} -t ipfs:" - It 'prints ipfs keys for duniter keys read in pubsec file' - When run keygen -i "${DUNITER_PUBSEC_FILE}" -t ipfs + Describe "-i ${DUNITER_PUBSEC_FILE} -t ipfs -pk:" + It 'prints prefixed ipfs keys for duniter keys read in pubsec file' + When run keygen -i "${DUNITER_PUBSEC_FILE}" -t ipfs -pk The output should include 'PeerID: 12D3KooWDMhdm5yrvtrbkshXFjkqLedHieUnPioczy9wzdnzquHC' The output should include 'PrivKEY: CAESQA+XqCWjRqCjNe9oU3QA796bEH+T+rxgyPQ/EkXvE2MvNJoTbvcP+m51+XwxrmWqHaOpI1ZD0USwLjqAmV8Boas=' The status should be success @@ -97,8 +147,33 @@ Describe 'keygen' rm -f "${DUNITER_PUBSEC_FILE}" "${IPFS_PEM_FILE}" End Describe '-t ipfs username password:' - It 'prints ipfs keys for user username' + It 'prints ipfs public key for user "username" with password "password"' When run keygen -t ipfs username password + The output should include '12D3KooWDMhdm5yrvtrbkshXFjkqLedHieUnPioczy9wzdnzquHC' + The status should be success + The stderr should equal "" + End + End + Describe '-t ipfs -s username password:' + It 'prints ipfs secret key for user "username" with password "password"' + When run keygen -t ipfs -s username password + The output should include 'CAESQA+XqCWjRqCjNe9oU3QA796bEH+T+rxgyPQ/EkXvE2MvNJoTbvcP+m51+XwxrmWqHaOpI1ZD0USwLjqAmV8Boas=' + The status should be success + The stderr should equal "" + End + End + Describe '-t ipfs -k username password:' + It 'prints ipfs keys for user "username" with password "password"' + When run keygen -t ipfs -k username password + The output should include '12D3KooWDMhdm5yrvtrbkshXFjkqLedHieUnPioczy9wzdnzquHC' + The output should include 'CAESQA+XqCWjRqCjNe9oU3QA796bEH+T+rxgyPQ/EkXvE2MvNJoTbvcP+m51+XwxrmWqHaOpI1ZD0USwLjqAmV8Boas=' + The status should be success + The stderr should equal "" + End + End + Describe '-t ipfs -pk username password:' + It 'prints prefixed ipfs keys for user "username" with password "password"' + When run keygen -t ipfs -pk username password The output should include 'PeerID: 12D3KooWDMhdm5yrvtrbkshXFjkqLedHieUnPioczy9wzdnzquHC' The output should include 'PrivKEY: CAESQA+XqCWjRqCjNe9oU3QA796bEH+T+rxgyPQ/EkXvE2MvNJoTbvcP+m51+XwxrmWqHaOpI1ZD0USwLjqAmV8Boas=' The status should be success @@ -106,7 +181,7 @@ Describe 'keygen' End End Describe "-o ${IPFS_PEM_FILE} -t ipfs username password:" - It 'writes ipfs keys to file for user username' + It 'writes ipfs keys to file for user "username" with password "password"' When run keygen username password -o "${IPFS_PEM_FILE}" -t ipfs The path "${IPFS_PEM_FILE}" should exist The contents of file "${IPFS_PEM_FILE}" should include '-----BEGIN PRIVATE KEY-----' @@ -126,36 +201,36 @@ Describe 'keygen' The status should be success End End - Describe '-g -t duniter username:' - It 'prints duniter keys for gpg key matching username' - When run keygen -g -t duniter username + Describe '-g -t duniter -pk username:' + It 'prints prefixed duniter keys for gpg key matching "username"' + When run keygen -g -t duniter -pk username The output should include 'pub: 2g5UL2zhkn5i7oNYDpWo3fBuWvRYVU1AbMtdVmnGzPNv' The output should include 'sec: 5WtYFfA26nTfG496gAKhkrLYUMMnwXexmE1E8Q7PvtQEyscHfirsdMzW34zDp7WEkt3exNEVwoG4ajZYrm62wpi2' The status should be success The stderr should equal "" End End - Describe '-g -t duniter username@protected password:' - It 'prints duniter keys for gpg key matching username@protected locked with password' - When run keygen -g -t duniter username@protected password + Describe '-g -t duniter -pk username@protected password:' + It 'prints prefixed duniter keys for gpg key matching "username@protected" locked with "password"' + When run keygen -g -t duniter -pk username@protected password The output should include 'pub: C1cRu7yb5rZhsmRHQkeZxusAhtYYJypcnXpY3HycEKsU' The output should include 'sec: VWaEdDroSCoagJDsBnDNUtXJtKAJYdqL6XKNiomz8DtiyF44FvpiMmhidXt2j8HhDBKPZ67xBGcZPnj4Myk6cB8' The status should be success The stderr should equal "" End End - Describe '-g -t ipfs username:' - It 'prints ipfs keys for gpg key matching username' - When run keygen -g -t ipfs username + Describe '-g -t ipfs -pk username:' + It 'prints prefixed ipfs keys for gpg key matching "username"' + When run keygen -g -t ipfs -pk username The output should include 'PeerID: 12D3KooWBVSe5AaQwgMCXgsxrRG8pTGk1FUBXA5eYxFeskwAtL6r' The output should include 'PrivKEY: CAESQOHXwPgzoiDca1ZnvhU/W3zdogZXulkoErnUsqt+ut82GN5k4MIbVvz2m6Vq0ij9fQFPNUz+ZZdv2D31K6mzBQc=' The status should be success The stderr should equal "" End End - Describe '-g -t ipfs username@protected password:' - It 'prints ipfs keys for gpg key matching username@protected locked with password' - When run keygen -g -t ipfs username@protected password + Describe '-g -t ipfs -pk username@protected password:' + It 'prints prefixed ipfs keys for gpg key matching "username@protected" locked with "password"' + When run keygen -g -t ipfs -pk username@protected password The output should include 'PeerID: 12D3KooWLpybeFZJGkqCHevi3MPujhx1CDbBLfu6k8BZRH8W8GbQ' The output should include 'PrivKEY: CAESQBiV+XnBNnryoeBs6SNj9e7Cd9Xj6INn24wyxxacylYqo5idwBHJto4Vbbp6NQzuUF+e7aCmrCf6y+BSyL42/i8=' The status should be success @@ -163,7 +238,7 @@ Describe 'keygen' End End Describe "-g -o ${DUNITER_PUBSEC_FILE} -t duniter username:" - It 'writes duniter keys to file for gpg key matching username' + It 'writes duniter keys to file for gpg key matching "username"' When run keygen -g -o "${DUNITER_PUBSEC_FILE}" -t duniter username The path "${DUNITER_PUBSEC_FILE}" should exist The contents of file "${DUNITER_PUBSEC_FILE}" should include 'pub: 2g5UL2zhkn5i7oNYDpWo3fBuWvRYVU1AbMtdVmnGzPNv' @@ -174,7 +249,7 @@ Describe 'keygen' rm -f "${DUNITER_PUBSEC_FILE}" End Describe "-g -o ${DUNITER_PUBSEC_FILE} -t duniter username@protected password:" - It 'writes duniter keys to file for gpg key matching username@protected locked with password' + It 'writes duniter keys to file for gpg key matching "username@protected" locked with "password"' When run keygen -g -o "${DUNITER_PUBSEC_FILE}" -t duniter username@protected password The path "${DUNITER_PUBSEC_FILE}" should exist The contents of file "${DUNITER_PUBSEC_FILE}" should include 'pub: C1cRu7yb5rZhsmRHQkeZxusAhtYYJypcnXpY3HycEKsU' @@ -185,7 +260,7 @@ Describe 'keygen' rm -f "${DUNITER_PUBSEC_FILE}" End Describe "-g -o ${IPFS_PEM_FILE} -t ipfs username:" - It 'writes ipfs keys to file for gpg key matching username' + It 'writes ipfs keys to file for gpg key matching "username"' When run keygen -g -o "${IPFS_PEM_FILE}" -t ipfs username The path "${IPFS_PEM_FILE}" should exist The contents of file "${IPFS_PEM_FILE}" should include '-----BEGIN PRIVATE KEY-----' @@ -197,7 +272,7 @@ Describe 'keygen' rm -f "${IPFS_PEM_FILE}" End Describe "-g -o ${IPFS_PEM_FILE} -t ipfs username@protected password:" - It 'writes ipfs keys to file for gpg key matching username@protected locked with password' + It 'writes ipfs keys to file for gpg key matching "username@protected" locked with "password"' When run keygen -g -o "${IPFS_PEM_FILE}" -t ipfs username@protected password The path "${IPFS_PEM_FILE}" should exist The contents of file "${IPFS_PEM_FILE}" should include '-----BEGIN PRIVATE KEY-----'