def gpg_app_create_key( blockchain_id, appname, keyname, txid=None, immutable=False, proxy=None, wallet_keys=None, config_dir=None ):
    """
    Create a new application GPG key.
    Use good defaults (RSA-4096)
    Stash it to the app-specific keyring locally.

    Return {'status': True, 'key_url': key_url, 'key_id': key fingerprint, ...} on success
    """

    assert is_valid_appname(appname)
    assert is_valid_keyname(keyname)

    if config_dir is None:
        config_dir = get_config_dir()

    client_config_path = os.path.join(config_dir, blockstack_client.CONFIG_FILENAME)
    if proxy is None:
        proxy = blockstack_client.get_default_proxy(config_path=client_config_path)

    keydir = make_gpg_tmphome( "create-app-", config_dir=config_dir )
    gpg = gnupg.GPG( homedir=keydir )

    log.debug("Generating GPG key (this may take a while)")

    key_input = gpg.gen_key_input( key_type="RSA", name_email=blockchain_id + "/" + appname, key_length=4096, name_real=keyname )
    key_res = gpg.gen_key( key_input )
    key_id = key_res.fingerprint
    key_data = gpg.export_keys( [key_id], secret=True )

    shutil.rmtree(keydir)

    # propagate to blockstack
    add_res = gpg_app_put_key( blockchain_id, appname, keyname, key_data, txid=txid, immutable=immutable, proxy=proxy, wallet_keys=wallet_keys, config_dir=config_dir )
    return add_res
def gpg_app_create_key ( blockchain_id , appname , keyname , txid = None , immutable = False , proxy = None , wallet_keys = None , config_dir = None ) : assert is_valid_appname ( appname ) assert is_valid_keyname ( keyname ) if config_dir is None : config_dir = get_config_dir ( ) client_config_path = os . path . join ( config_dir , blockstack_client . CONFIG_FILENAME ) if proxy is None : proxy = blockstack_client . get_default_proxy ( config_path = client_config_path ) keydir = make_gpg_tmphome ( "create-app-" , config_dir = config_dir ) gpg = gnupg . GPG ( homedir = keydir ) log . debug ( "Generating GPG key (this may take a while)" ) key_input = gpg . gen_key_input ( key_type = "RSA" , name_email = blockchain_id + "/" + appname , key_length = 4096 , name_real = keyname ) key_res = gpg . gen_key ( key_input ) key_id = key_res . fingerprint key_data = gpg . export_keys ( [ key_id ] , secret = True ) shutil . rmtree ( keydir ) add_res = gpg_app_put_key ( blockchain_id , appname , keyname , key_data , txid = txid , immutable = immutable , proxy = proxy , wallet_keys = wallet_keys , config_dir = config_dir ) return add_res
Create a new application GPG key.
    Use good defaults (RSA-4096)
    Stash it to the app-specific keyring locally.

    Return {'status': True, 'key_url': key_url, 'key_id': key fingerprint, ...} on success