Instruction:
Can you generate the documentation for the following Python 3 function
async def build_revoc_reg_entry_request(submitter_did: str,
                                        revoc_reg_def_id: str,
                                        rev_def_type: str,
                                        value: str) -> str:
    """
    Builds a REVOC_REG_ENTRY request.  Request to add the RevocReg entry containing
    the new accumulator value and issued/revoked indices.
    This is just a delta of indices, not the whole list. So, it can be sent each time a new credential is issued/revoked.

    :param submitter_did: DID of the submitter stored in secured Wallet.
    :param revoc_reg_def_id:  ID of the corresponding RevocRegDef.
    :param rev_def_type:  Revocation Registry type (only CL_ACCUM is supported for now).
    :param value: Registry-specific data:
       {
           value: {
               prevAccum: string - previous accumulator value.
               accum: string - current accumulator value.
               issued: array<number> - an array of issued indices.
               revoked: array<number> an array of revoked indices.
           },
           ver: string - version revocation registry entry json

       }
    :return: Request result as json.
    """

    logger = logging.getLogger(__name__)
    logger.debug("build_revoc_reg_entry_request: >>> submitter_did: %r, rev_def_type: %r, revoc_reg_def_id: %r, "
                 "value: %r", submitter_did, rev_def_type, revoc_reg_def_id, value)

    if not hasattr(build_revoc_reg_entry_request, "cb"):
        logger.debug("build_revoc_reg_entry_request: Creating callback")
        build_revoc_reg_entry_request.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p))

    c_submitter_did = c_char_p(submitter_did.encode('utf-8'))
    c_rev_def_type = c_char_p(rev_def_type.encode('utf-8'))
    c_revoc_reg_def_id = c_char_p(revoc_reg_def_id.encode('utf-8'))
    c_value = c_char_p(value.encode('utf-8'))

    request_json = await do_call('indy_build_revoc_reg_entry_request',
                                 c_submitter_did,
                                 c_revoc_reg_def_id,
                                 c_rev_def_type,
                                 c_value,
                                 build_revoc_reg_entry_request.cb)

    res = request_json.decode()
    logger.debug("build_revoc_reg_entry_request: <<< res: %r", res)
    return res

Response: Builds a REVOC_REG_ENTRY request. Request to add a Revocation Registry entry to the list of revocation registry entries.


Instruction:
Explain what the following Python 3 code does
async def build_get_revoc_reg_request(submitter_did: Optional[str],
                                      revoc_reg_def_id: str,
                                      timestamp: int) -> str:
    """
    Builds a GET_REVOC_REG request. Request to get the accumulated state of the Revocation Registry
    by ID. The state is defined by the given timestamp.

    :param submitter_did: (Optional) DID of the read request sender (if not provided then default Libindy DID will be used).
    :param revoc_reg_def_id:  ID of the corresponding Revocation Registry Definition in ledger.
    :param timestamp: Requested time represented as a total number of seconds from Unix Epoch
    :return: Request result as json.
    """

    logger = logging.getLogger(__name__)
    logger.debug("build_get_revoc_reg_request: >>> submitter_did: %r, revoc_reg_def_id: %r, timestamp: %r",
                 submitter_did, revoc_reg_def_id, timestamp)

    if not hasattr(build_get_revoc_reg_request, "cb"):
        logger.debug("build_get_revoc_reg_request: Creating callback")
        build_get_revoc_reg_request.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p))

    c_submitter_did = c_char_p(submitter_did.encode('utf-8')) if submitter_did is not None else None
    c_revoc_reg_def_id = c_char_p(revoc_reg_def_id.encode('utf-8'))
    c_timestamp = c_int64(timestamp)

    request_json = await do_call('indy_build_get_revoc_reg_request',
                                 c_submitter_did,
                                 c_revoc_reg_def_id,
                                 c_timestamp,
                                 build_get_revoc_reg_request.cb)

    res = request_json.decode()
    logger.debug("build_get_revoc_reg_request: <<< res: %r", res)
    return res

Response: Builds a GET_REVOC_REG request. Request to get the accumulated state of the Revocation Registry by ID.


Instruction:
Implement a Python 3 function for
parsing a GET_REVOC_REG response to get Revocation Registry in the format compatible with Anoncreds API.

Response:
async def parse_get_revoc_reg_response(get_revoc_reg_response: str) -> (str, str, int):
    """
    Parse a GET_REVOC_REG response to get Revocation Registry in the format compatible with Anoncreds API.

    :param get_revoc_reg_response: response of GET_REVOC_REG request.
    :return: Revocation Registry Definition Id, Revocation Registry json and Timestamp.
      {
          "value": Registry-specific data {
              "accum": string - current accumulator value.
          },
          "ver": string - version revocation registry json
      }
    """

    logger = logging.getLogger(__name__)
    logger.debug("parse_get_revoc_reg_response: >>> get_revoc_reg_response: %r", get_revoc_reg_response)

    if not hasattr(parse_get_revoc_reg_response, "cb"):
        logger.debug("parse_get_revoc_reg_response: Creating callback")
        parse_get_revoc_reg_response.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p, c_char_p, c_uint64))

    c_get_revoc_reg_response = c_char_p(get_revoc_reg_response.encode('utf-8'))

    (revoc_reg_def_id, revoc_reg_json, timestamp) = await do_call('indy_parse_get_revoc_reg_response',
                                                                  c_get_revoc_reg_response,
                                                                  parse_get_revoc_reg_response.cb)

    res = (revoc_reg_def_id.decode(), revoc_reg_json.decode(), timestamp)
    logger.debug("parse_get_revoc_reg_response: <<< res: %r", res)
    return res


Instruction:
Make a summary of the following Python 3 code
async def build_get_revoc_reg_delta_request(submitter_did: Optional[str],
                                            revoc_reg_def_id: str,
                                            from_: Optional[int],
                                            to: int) -> str:
    """
    Builds a GET_REVOC_REG_DELTA request. Request to get the delta of the accumulated state of the Revocation Registry.
    The Delta is defined by from and to timestamp fields.
    If from is not specified, then the whole state till to will be returned.

    :param submitter_did: (Optional) DID of the read request sender (if not provided then default Libindy DID will be used).
    :param revoc_reg_def_id:  ID of the corresponding Revocation Registry Definition in ledger.
    :param from_: Requested time represented as a total number of seconds from Unix Epoch
    :param to: Requested time represented as a total number of seconds from Unix Epoch
    :return: Request result as json.
    """

    logger = logging.getLogger(__name__)
    logger.debug("build_get_revoc_reg_delta_request: >>> submitter_did: %r, revoc_reg_def_id: %r, from: %r, to: %r",
                 submitter_did, revoc_reg_def_id, from_, to)

    if not hasattr(build_get_revoc_reg_delta_request, "cb"):
        logger.debug("build_get_revoc_reg_delta_request: Creating callback")
        build_get_revoc_reg_delta_request.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p))

    c_submitter_did = c_char_p(submitter_did.encode('utf-8')) if submitter_did is not None else None
    c_revoc_reg_def_id = c_char_p(revoc_reg_def_id.encode('utf-8'))
    c_from = c_int64(from_) if from_  else -1
    c_to = c_int64(to)

    request_json = await do_call('indy_build_get_revoc_reg_delta_request',
                                 c_submitter_did,
                                 c_revoc_reg_def_id,
                                 c_from,
                                 c_to,
                                 build_get_revoc_reg_delta_request.cb)

    res = request_json.decode()
    logger.debug("build_get_revoc_reg_delta_request: <<< res: %r", res)
    return res

Response: Builds a GET_REVOC_REG_DELTA request. Request to get the delta of the accumulated state of the Revocation Registry.


Instruction:
Create a Python 3 function to
parse a GET_REVOC_REG_DELTA response to get Revocation Registry Delta json and Timestamp.

Response:
async def parse_get_revoc_reg_delta_response(get_revoc_reg_delta_response: str) -> (str, str, int):
    """
    Parse a GET_REVOC_REG_DELTA response to get Revocation Registry Delta in the format compatible with Anoncreds API.

    :param get_revoc_reg_delta_response: response of GET_REVOC_REG_DELTA request.
    :return: Revocation Registry Definition Id, Revocation Registry Delta json and Timestamp.
      {
          "value": Registry-specific data {
              prevAccum: string - previous accumulator value.
              accum: string - current accumulator value.
              issued: array<number> - an array of issued indices.
              revoked: array<number> an array of revoked indices.
          },
          "ver": string
      }
    """

    logger = logging.getLogger(__name__)
    logger.debug("parse_get_revoc_reg_delta_response: >>> get_revoc_reg_delta_response: %r",
                 get_revoc_reg_delta_response)

    if not hasattr(parse_get_revoc_reg_delta_response, "cb"):
        logger.debug("parse_get_revoc_reg_delta_response: Creating callback")
        parse_get_revoc_reg_delta_response.cb = create_cb(
            CFUNCTYPE(None, c_int32, c_int32, c_char_p, c_char_p, c_uint64))

    c_get_revoc_reg_delta_response = c_char_p(get_revoc_reg_delta_response.encode('utf-8'))

    (revoc_reg_def_id, revoc_reg_delta_json, timestamp) = await do_call('indy_parse_get_revoc_reg_delta_response',
                                                                        c_get_revoc_reg_delta_response,
                                                                        parse_get_revoc_reg_delta_response.cb)

    res = (revoc_reg_def_id.decode(), revoc_reg_delta_json.decode(), timestamp)
    logger.debug("parse_get_revoc_reg_delta_response: <<< res: %r", res)
    return res


Instruction:
Can you tell what is the following Python 3 function doing
async def get_response_metadata(response: str) -> str:

    logger = logging.getLogger(__name__)
    logger.debug("get_response_metadata: >>> response: %r",
                 response)

    if not hasattr(get_response_metadata, "cb"):
        logger.debug("get_response_metadata: Creating callback")
        get_response_metadata.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p))

    c_response = c_char_p(response.encode('utf-8'))

    response_metadata = await do_call('indy_get_response_metadata',
                                      c_response,
                                      get_response_metadata.cb)

    res = response_metadata.decode()
    logger.debug("get_response_metadata: <<< res: %r", res)
    return res

Response: Parse response to get metadata.


Instruction:
Make a summary of the following Python 3 code
async def build_auth_rule_request(submitter_did: str,
                                  txn_type: str,
                                  action: str,
                                  field: str,
                                  old_value: Optional[str],
                                  new_value: Optional[str],
                                  constraint: str) -> str:
    """
    Builds a AUTH_RULE request. Request to change authentication rules for a ledger transaction.

    :param submitter_did: DID of the submitter stored in secured Wallet.
    :param txn_type: ledger transaction alias or associated value.
    :param action: type of an action.
       Can be either "ADD" (to add a new rule) or "EDIT" (to edit an existing one).
    :param field: transaction field.
    :param old_value: (Optional) old value of a field, which can be changed to a new_value (mandatory for EDIT action).
    :param new_value: (Optional) new value that can be used to fill the field.
    :param constraint: set of constraints required for execution of an action in the following format:
        {
            constraint_id - <string> type of a constraint.
                Can be either "ROLE" to specify final constraint or  "AND"/"OR" to combine constraints.
            role - <string> role of a user which satisfy to constrain.
            sig_count - <u32> the number of signatures required to execution action.
            need_to_be_owner - <bool> if user must be an owner of transaction.
            metadata - <object> additional parameters of the constraint.
        }
      can be combined by
        {
            'constraint_id': <"AND" or "OR">
            'auth_constraints': [<constraint_1>, <constraint_2>]
        }

    Default ledger auth rules: https://github.com/hyperledger/indy-node/blob/master/docs/source/auth_rules.md

    More about AUTH_RULE request: https://github.com/hyperledger/indy-node/blob/master/docs/source/requests.md#auth_rule

    :return: Request result as json.
    """

    logger = logging.getLogger(__name__)
    logger.debug("build_auth_rule_request: >>> submitter_did: %r, txn_type: %r, action: %r, field: %r, "
                 "old_value: %r, new_value: %r, constraint: %r",
                 submitter_did,
                 txn_type,
                 action,
                 field,
                 old_value,
                 new_value,
                 constraint)

    if not hasattr(build_auth_rule_request, "cb"):
        logger.debug("build_auth_rule_request: Creating callback")
        build_auth_rule_request.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p))

    c_submitter_did = c_char_p(submitter_did.encode('utf-8'))
    c_txn_type = c_char_p(txn_type.encode('utf-8'))
    c_action = c_char_p(action.encode('utf-8'))
    c_field = c_char_p(field.encode('utf-8'))
    c_old_value = c_char_p(old_value.encode('utf-8')) if old_value is not None else None
    c_new_value = c_char_p(new_value.encode('utf-8')) if new_value is not None else None
    c_constraint = c_char_p(constraint.encode('utf-8'))

    request_json = await do_call('indy_build_auth_rule_request',
                                 c_submitter_did,
                                 c_txn_type,
                                 c_action,
                                 c_field,
                                 c_old_value,
                                 c_new_value,
                                 c_constraint,
                                 build_auth_rule_request.cb)

    res = request_json.decode()
    logger.debug("build_auth_rule_request: <<< res: %r", res)
    return res

Response: Builds a AUTH_RULE request.


Instruction:
Write a Python 3 script for
creating a new DID and store it in a secured Wallet.

Response:
async def create_and_store_my_did(wallet_handle: int,
                                  did_json: str) -> (str, str):
    """
    Creates keys (signing and encryption keys) for a new
    DID (owned by the caller of the library).
    Identity's DID must be either explicitly provided, or taken as the first 16 bit of verkey.
    Saves the Identity DID with keys in a secured Wallet, so that it can be used to sign
    and encrypt transactions.

    :param wallet_handle: wallet handler (created by open_wallet).
    :param did_json: Identity information as json. Example:
        {
            "did": string, (optional;
                    if not provided and cid param is false then the first 16 bit of the verkey will be
                    used as a new DID;
                    if not provided and cid is true then the full verkey will be used as a new DID;
                    if provided, then keys will be replaced - key rotation use case)
	        "seed": string, (optional) Seed that allows deterministic key creation (if not set random one will be created).
	                                    Can be UTF-8, base64 or hex string.
            "crypto_type": string, (optional; if not set then ed25519 curve is used;
                      currently only 'ed25519' value is supported for this field)
            "cid": bool, (optional; if not set then false is used;)
        }
    :return: DID and verkey (for verification of signature)
    """

    logger = logging.getLogger(__name__)
    logger.debug("create_and_store_my_did: >>> wallet_handle: %r, did_json: %r",
                 wallet_handle,
                 did_json)

    if not hasattr(create_and_store_my_did, "cb"):
        logger.debug("create_wallet: Creating callback")
        create_and_store_my_did.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p, c_char_p))

    c_wallet_handle = c_int32(wallet_handle)
    c_did_json = c_char_p(did_json.encode('utf-8'))

    did, verkey = await do_call('indy_create_and_store_my_did',
                                c_wallet_handle,
                                c_did_json,
                                create_and_store_my_did.cb)

    res = (did.decode(), verkey.decode())

    logger.debug("create_and_store_my_did: <<< res: %r", res)
    return res


Instruction:
How would you code a function in Python 3 to
generate new keys (signing and encryption keys) for an existing DID (owned by the caller of the library). :param wallet_handle: wallet handler (created by open_wallet). :param did: signing DID :param identity_json: Identity information as json. Example: { "seed": string, (optional) Seed that allows deterministic key creation (if not set random one will be created). Can be UTF-8, base64 or hex string. "crypto_type": string, (optional; if not set then ed25519 curve is used; currently only 'ed25519' value is supported for this field) } :return: verkey

Response:
async def replace_keys_start(wallet_handle: int,
                             did: str,
                             identity_json: str) -> str:
    """
    Generated new keys (signing and encryption keys) for an existing
    DID (owned by the caller of the library).

    :param wallet_handle: wallet handler (created by open_wallet).
    :param did: signing DID
    :param identity_json: Identity information as json. Example:
        {
	        "seed": string, (optional) Seed that allows deterministic key creation (if not set random one will be created).
	                                   Can be UTF-8, base64 or hex string.
            "crypto_type": string, (optional; if not set then ed25519 curve is used;
                      currently only 'ed25519' value is supported for this field)
        }
    :return: verkey
    """

    logger = logging.getLogger(__name__)
    logger.debug("replace_keys_start: >>> wallet_handle: %r, did: %r, identity_json: %r",
                 wallet_handle,
                 did,
                 identity_json)

    if not hasattr(replace_keys_start, "cb"):
        logger.debug("replace_keys_start: Creating callback")
        replace_keys_start.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p))

    c_wallet_handle = c_int32(wallet_handle)
    c_did = c_char_p(did.encode('utf-8'))
    c_identity_json = c_char_p(identity_json.encode('utf-8'))

    verkey = await do_call('indy_replace_keys_start',
                           c_wallet_handle,
                           c_did,
                           c_identity_json,
                           replace_keys_start.cb)

    res = verkey.decode()

    logger.debug("replace_keys_start: <<< res: %r", res)
    return res


Instruction:
How would you code a function in Python 3 to
apply temporary keys as main for an existing DID.

Response:
async def replace_keys_apply(wallet_handle: int,
                             did: str) -> None:
    """
    Apply temporary keys as main for an existing DID (owned by the caller of the library).

    :param wallet_handle: wallet handler (created by open_wallet).
    :param did: The DID to resolve key.
    :return: Error code
    """

    logger = logging.getLogger(__name__)
    logger.debug("replace_keys_apply: >>> wallet_handle: %r, did: %r",
                 wallet_handle,
                 did)

    if not hasattr(replace_keys_apply, "cb"):
        logger.debug("replace_keys_apply: Creating callback")
        replace_keys_apply.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32))

    c_wallet_handle = c_int32(wallet_handle)
    c_did = c_char_p(did.encode('utf-8'))

    await do_call('indy_replace_keys_apply',
                  c_wallet_handle,
                  c_did,
                  replace_keys_apply.cb)

    logger.debug("replace_keys_apply: <<<")


Instruction:
Write a Python 3 function that can
store their DID for a pairwise connection in a secured Wallet.

Response:
async def store_their_did(wallet_handle: int,
                          identity_json: str) -> None:
    """
    Saves their DID for a pairwise connection in a secured Wallet,
    so that it can be used to verify transaction.

    :param wallet_handle: wallet handler (created by open_wallet).
    :param identity_json: Identity information as json. Example:
        {
           "did": string, (required)
           "verkey": string (optional, if only pk is provided),
           "crypto_type": string, (optional; if not set then ed25519 curve is used;
                  currently only 'ed25519' value is supported for this field)
        }
    :return: None
    """

    logger = logging.getLogger(__name__)
    logger.debug("store_their_did: >>> wallet_handle: %r, identity_json: %r",
                 wallet_handle,
                 identity_json)

    if not hasattr(store_their_did, "cb"):
        logger.debug("store_their_did: Creating callback")
        store_their_did.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32))

    c_wallet_handle = c_int32(wallet_handle)
    c_identity_json = c_char_p(identity_json.encode('utf-8'))

    res = await do_call('indy_store_their_did',
                        c_wallet_handle,
                        c_identity_json,
                        store_their_did.cb)

    logger.debug("store_their_did: <<< res: %r", res)
    return res


Instruction:
Can you tell what is the following Python 3 function doing
async def create_key(wallet_handle: int,
                     key_json: str) -> str:
    """
    Creates keys pair and stores in the wallet.

    :param wallet_handle: Wallet handle (created by open_wallet).
    :param key_json: Key information as json. Example:
        {
	        "seed": string, (optional) Seed that allows deterministic key creation (if not set random one will be created).
	                                   Can be UTF-8, base64 or hex string.
            "crypto_type": string, // Optional (if not set then ed25519 curve is used);
                    Currently only 'ed25519' value is supported for this field.
        }
    :return: verkey: Ver key of generated key pair, also used as key identifier
    """

    logger = logging.getLogger(__name__)
    logger.debug("create_key: >>> wallet_handle: %r, key_json: %r",
                 wallet_handle,
                 key_json)

    if not hasattr(create_key, "cb"):
        logger.debug("create_key: Creating callback")
        create_key.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p))

    c_wallet_handle = c_int32(wallet_handle)
    c_key_json = c_char_p(key_json.encode('utf-8'))

    verkey = await do_call('indy_create_key',
                           c_wallet_handle,
                           c_key_json,
                           create_key.cb)

    res = verkey.decode()

    logger.debug("create_key: <<< res: %r", res)
    return res

Response: Create a new key pair and stores it in the wallet.


Instruction:
Can you generate the documentation for the following Python 3 function
async def set_key_metadata(wallet_handle: int,
                           verkey: str,
                           metadata: str) -> None:
    """
    Creates keys pair and stores in the wallet.

    :param wallet_handle: Wallet handle (created by open_wallet).
    :param verkey: the key (verkey, key id) to store metadata.
    :param metadata: the meta information that will be store with the key.
    :return: Error code
    """

    logger = logging.getLogger(__name__)
    logger.debug("set_key_metadata: >>> wallet_handle: %r, verkey: %r, metadata: %r",
                 wallet_handle,
                 verkey,
                 metadata)

    if not hasattr(set_key_metadata, "cb"):
        logger.debug("set_key_metadata: Creating callback")
        set_key_metadata.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32))

    c_wallet_handle = c_int32(wallet_handle)
    c_verkey = c_char_p(verkey.encode('utf-8'))
    c_metadata = c_char_p(metadata.encode('utf-8'))

    await do_call('indy_set_key_metadata',
                  c_wallet_handle,
                  c_verkey,
                  c_metadata,
                  set_key_metadata.cb)

    logger.debug("create_key: <<<")

Response: Create keys pair and stores in the wallet.


Instruction:
Write a Python 3 script to
retrieve the meta information for the given key in the wallet.

Response:
async def get_key_metadata(wallet_handle: int,
                           verkey: str) -> str:
    """
    Retrieves the meta information for the giving key in the wallet.

    :param wallet_handle: Wallet handle (created by open_wallet).
    :param verkey: The key (verkey, key id) to retrieve metadata.
    :return: metadata: The meta information stored with the key; Can be null if no metadata was saved for this key.
    """

    logger = logging.getLogger(__name__)
    logger.debug("get_key_metadata: >>> wallet_handle: %r, verkey: %r",
                 wallet_handle,
                 verkey)

    if not hasattr(get_key_metadata, "cb"):
        logger.debug("get_key_metadata: Creating callback")
        get_key_metadata.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p))

    c_wallet_handle = c_int32(wallet_handle)
    c_verkey = c_char_p(verkey.encode('utf-8'))

    metadata = await do_call('indy_get_key_metadata',
                             c_wallet_handle,
                             c_verkey,
                             get_key_metadata.cb)

    res = metadata.decode()

    logger.debug("get_key_metadata: <<< res: %r", res)
    return res


Instruction:
Given the following Python 3 function, write the documentation
async def set_endpoint_for_did(wallet_handle: int,
                               did: str,
                               address: str,
                               transport_key: str) -> None:
    """
    Set/replaces endpoint information for the given DID.

    :param wallet_handle: Wallet handle (created by open_wallet).
    :param did: The DID to resolve endpoint.
    :param address: The DIDs endpoint address.
    :param transport_key: The DIDs transport key (ver key, key id).
    :return: Error code
    """

    logger = logging.getLogger(__name__)
    logger.debug("set_endpoint_for_did: >>> wallet_handle: %r, did: %r, address: %r, transport_key: %r",
                 wallet_handle,
                 did,
                 address,
                 transport_key)

    if not hasattr(set_endpoint_for_did, "cb"):
        logger.debug("set_endpoint_for_did: Creating callback")
        set_endpoint_for_did.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32))

    c_wallet_handle = c_int32(wallet_handle)
    c_did = c_char_p(did.encode('utf-8'))
    c_address = c_char_p(address.encode('utf-8'))
    c_transport_key = c_char_p(transport_key.encode('utf-8'))

    await do_call('indy_set_endpoint_for_did',
                  c_wallet_handle,
                  c_did,
                  c_address,
                  c_transport_key,
                  set_endpoint_for_did.cb)

    logger.debug("set_endpoint_for_did: <<<")

Response: Set endpoint information for the given DID.


Instruction:
Create a Python 3 function for
getting endpoint information for a given DID.

Response:
async def get_endpoint_for_did(wallet_handle: int,
                               pool_handle: int,
                               did: str) -> (str, Optional[str]):
    """
    Returns endpoint information for the given DID.

    :param wallet_handle: Wallet handle (created by open_wallet).
    :param pool_handle: Pool handle (created by open_pool).
    :param did: The DID to resolve endpoint.
    :return: (endpoint, transport_vk)
    """

    logger = logging.getLogger(__name__)
    logger.debug("get_endpoint_for_did: >>> wallet_handle: %r, pool_handle: %r, did: %r",
                 wallet_handle,
                 pool_handle,
                 did)

    if not hasattr(get_endpoint_for_did, "cb"):
        logger.debug("get_endpoint_for_did: Creating callback")
        get_endpoint_for_did.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p, c_char_p))

    c_wallet_handle = c_int32(wallet_handle)
    c_pool_handle = c_int32(pool_handle)
    c_did = c_char_p(did.encode('utf-8'))

    endpoint, transport_vk = await do_call('indy_get_endpoint_for_did',
                                           c_wallet_handle,
                                           c_pool_handle,
                                           c_did,
                                           get_endpoint_for_did.cb)

    endpoint = endpoint.decode()
    transport_vk = transport_vk.decode() if transport_vk is not None else None
    res = (endpoint, transport_vk)

    logger.debug("get_endpoint_for_did: <<< res: %r", res)
    return res


Instruction:
Can you generate the documentation for the following Python 3 function
async def set_did_metadata(wallet_handle: int,
                           did: str,
                           metadata: str) -> None:
    """
    Saves/replaces the meta information for the giving DID in the wallet.

    :param wallet_handle: Wallet handle (created by open_wallet).
    :param did: the DID to store metadata.
    :param metadata: the meta information that will be store with the DID.
    :return: Error code
    """

    logger = logging.getLogger(__name__)
    logger.debug("set_did_metadata: >>> wallet_handle: %r, did: %r, metadata: %r",
                 wallet_handle,
                 did,
                 metadata)

    if not hasattr(set_did_metadata, "cb"):
        logger.debug("set_did_metadata: Creating callback")
        set_did_metadata.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32))

    c_wallet_handle = c_int32(wallet_handle)
    c_did = c_char_p(did.encode('utf-8'))
    c_metadata = c_char_p(metadata.encode('utf-8'))

    await do_call('indy_set_did_metadata',
                  c_wallet_handle,
                  c_did,
                  c_metadata,
                  set_did_metadata.cb)

    logger.debug("set_did_metadata: <<<")

Response: Sets the meta information for the given DID in the wallet.


Instruction:
Can you implement a function in Python 3 that
gets DID metadata and verkey stored in the wallet.

Response:
async def get_my_did_with_meta(wallet_handle: int, did: str) -> str:
    """
    Get DID metadata and verkey stored in the wallet.

    :param wallet_handle: wallet handler (created by open_wallet).
    :param did: The DID to retrieve metadata.
    :return: DID with verkey and metadata.
    """

    logger = logging.getLogger(__name__)
    logger.debug("get_my_did_with_meta: >>> wallet_handle: %r, did: %r",
                 wallet_handle,
                 did)

    if not hasattr(get_my_did_with_meta, "cb"):
        logger.debug("get_my_did_with_meta: Creating callback")
        get_my_did_with_meta.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p))

    c_wallet_handle = c_int32(wallet_handle)
    c_did = c_char_p(did.encode('utf-8'))

    did_with_meta = await do_call('indy_get_my_did_with_meta',
                                  c_wallet_handle,
                                  c_did,
                                  get_my_did_with_meta.cb)

    res = did_with_meta.decode()

    logger.debug("get_my_did_with_meta: <<< res: %r", res)
    return res


Instruction:
Here you have a function in Python 3, explain what it does
async def abbreviate_verkey(did: str,
                          full_verkey: str) -> str:
    """
    Retrieves abbreviated verkey if it is possible otherwise return full verkey.

    :param did: The DID.
    :param full_verkey: The DIDs verification key,
    :return: metadata: Either abbreviated or full verkey.
    """

    logger = logging.getLogger(__name__)
    logger.debug("abbreviate_verkey: >>> did: %r, full_verkey: %r",
                 did, full_verkey)

    if not hasattr(abbreviate_verkey, "cb"):
        logger.debug("abbreviate_verkey: Creating callback")
        abbreviate_verkey.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p))

    c_did = c_char_p(did.encode('utf-8'))
    c_full_verkey = c_char_p(full_verkey.encode('utf-8'))

    metadata = await do_call('indy_abbreviate_verkey',
                             c_did,
                             c_full_verkey,
                             abbreviate_verkey.cb)

    res = metadata.decode()

    logger.debug("abbreviate_verkey: <<< res: %r", res)
    return res

Response: Returns the full verkey for the given DID.


Instruction:
Implement a function in Python 3 to
create a credential with an offer.

Response:
async def create(source_id: str, credential_offer: str):
        """
        Creates a credential with an offer.
        :param source_id: user defined id of object.
        :param credential_offer: JSON string representing the offer used as the basis of creation.
        :return: A created credential
        Example:
        offer = [{
           "msg_type": "CLAIM_OFFER",
           "version": "0.1",
           "to_did": "8XFh8yBzrpJQmNyZzgoTqB",
           "from_did": "8XFh8yBzrpJQmNyZzgoTqB",
           "libindy_offer": '{}',
           "credential_attrs": {
              "address1": [
                 "101 Tela Lane"
              ],
              "address2": [
                 "101 Wilson Lane"
              ],
              "city": [
                 "SLC"
              ],
              "state": [
                 "UT"
              ],
              "zip": [
                 "87121"
              ]
           },
           "schema_seq_no": 1487,
           "cred_def_id": "id1",
           "claim_name": "Credential",
           "claim_id": "defaultCredentialId",
           "msg_ref_id": None,
        }]
        credential = await Credential.create(source_id, offer)
        """
        constructor_params = (source_id,)

        c_source_id = c_char_p(source_id.encode('utf-8'))
        c_offer = c_char_p(json.dumps(credential_offer).encode('utf-8'))
        c_params = (c_source_id, c_offer, )

        return await Credential._create("vcx_credential_create_with_offer",
                                        constructor_params,
                                        c_params)


Instruction:
Write a Python 3 script for
creating a new credential based off of a known message id.

Response:
async def create_with_msgid(source_id: str, connection: Connection, msg_id: str):
        """
        Create a credential based off of a known message id for a given connection.
        :param source_id: user defined id of object.
        :param connection: connection handle of connection to receive offer from
        :param msg_id: message id
        :return: A created credential
        Example:
        credential = await Credential.create_with_msgid(source_id, connection, msg_id)
        assert await credential.get_state() == State.RequestReceived
        """
        credential = Credential(source_id,)

        c_source_id = c_char_p(source_id.encode('utf-8'))
        c_msg_id = c_char_p(json.dumps(msg_id).encode('utf-8'))
        c_connection_handle = c_uint32(connection.handle)

        if not hasattr(Credential.create_with_msgid, "cb"):
            Credential.create_with_msgid.cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32, c_uint32, c_char_p))

        credential.handle, cred_offer = await do_call('vcx_credential_create_with_msgid',
                                                      c_source_id,
                                                      c_connection_handle,
                                                      c_msg_id,
                                                      Credential.create_with_msgid.cb)

        credential.cred_offer = json.loads(cred_offer.decode())

        return credential


Instruction:
Can you implement a function in Python 3 that
creates a credential object from a previously serialized credential object.

Response:
async def deserialize(data: dict):
        """
        Create a credential object from a previously serialized credential object
        :param data: JSON data from a serialized object.
        :return: A created credential
        Example:
        credential = await Credential.create(source_id, offer)
        data = await credential.serialize()
        credential2 = await Credential.deserialize(data)
        """

        credential = await Credential._deserialize("vcx_credential_deserialize",
                                                   json.dumps(data),
                                                   data.get('data').get('source_id'))
        return credential


Instruction:
Create a Python 3 function to
retrieve all pending credential offers for a given connection.

Response:
async def get_offers(connection: Connection) -> dict:
        """
        Retrieves all pending credential offers for a given connection.
        :param connection: A connection handle
        :return: A list of dictionary objects representing offers from a given connection.
        Example:
        credential = await Credential.create_with_msgid(source_id, connection, msg_id)
        offers = await credential.get_offers(connection)
        """
        if not hasattr(Credential.get_offers, "cb"):
            Credential.get_offers.cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32, c_char_p))

        c_connection_handle = c_uint32(connection.handle)

        data = await do_call('vcx_credential_get_offers',
                             c_connection_handle,
                             Credential.get_offers.cb)

        return json.loads(data.decode())


Instruction:
Can you generate a brief explanation for the following Python 3 code
async def send_request(self, connection: Connection, payment_handle: int):
        if not hasattr(Credential.send_request, "cb"):
            self.logger.debug("vcx_credential_send_request: Creating callback")
            Credential.send_request.cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32))

        c_credential_handle = c_uint32(self.handle)
        c_connection_handle = c_uint32(connection.handle)
        c_payment = c_uint32(payment_handle)

        await do_call('vcx_credential_send_request',
                      c_credential_handle,
                      c_connection_handle,
                      c_payment,
                      Credential.send_request.cb)

Response: Sends a credential request to the prover s wallet.


Instruction:
Write a Python 3 script for
retrieving Payment Transaction Information for this Credential.

Response:
async def get_payment_info(self):
        """
        Retrieve Payment Transaction Information for this Credential. Typically this will include
        how much payment is requried by the issuer, which needs to be provided by the prover, before the issuer will
        issue the credential to the prover. Ideally a prover would want to know how much payment is being asked before
        submitting the credential request (which triggers the payment to be made).
        Example:
        info = credential.get_payment_info()
        :return:
        """
        if not hasattr(Credential.get_payment_info, "cb"):
            self.logger.debug("vcx_credential_get_payment_info: Creating callback")
            Credential.get_payment_info.cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32, c_char_p))

        c_credential_handle = c_uint32(self.handle)
        data = await do_call('vcx_credential_get_payment_info',
                      c_credential_handle,
                      Credential.get_payment_info.cb)
        return json.loads(data.decode())


Instruction:
Can you generate a brief explanation for the following Python 3 code
async def get_payment_txn(self):
        if not hasattr(Credential.get_payment_txn, "cb"):
            self.logger.debug("vcx_credential_get_payment_txn: Creating callback")
            Credential.get_payment_txn.cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32, c_char_p))

        c_credential_handle = c_uint32(self.handle)

        payment_txn = await do_call('vcx_credential_get_payment_txn',
                      c_credential_handle,
                      Credential.get_payment_txn.cb)

        return json.loads(payment_txn.decode())

Response: Retirieve the payment transaction associated with this credential.


Instruction:
Can you implement a function in Python 3 that
creates a connection object representing a single endpoint and can be used for sending and receiving and proofs of a connection.

Response:
async def create(source_id: str):
        """
        Create a connection object, represents a single endpoint and can be used for sending and receiving
        credentials and proofs

        :param source_id: Institution's unique ID for the connection
        :return: connection object
        Example:
        connection = await Connection.create(source_id)
        """
        constructor_params = (source_id,)

        c_source_id = c_char_p(source_id.encode('utf-8'))
        c_params = (c_source_id,)

        return await Connection._create( "vcx_connection_create",
                                        constructor_params,
                                        c_params)


Instruction:
Make a summary of the following Python 3 code
async def create_with_details(source_id: str, invite_details: str):
        constructor_params = (source_id,)

        c_source_id = c_char_p(source_id.encode('utf-8'))
        c_invite_details = c_char_p(invite_details.encode('utf-8'))

        c_params = (c_source_id, c_invite_details, )

        return await Connection._create( "vcx_connection_create_with_invite",
                                        constructor_params,
                                        c_params)

Response: Create a connection object with a provided invite.


Instruction:
Can you generate a brief explanation for the following Python 3 code
async def deserialize(data: dict):
        return await Connection._deserialize("vcx_connection_deserialize",
                                             json.dumps(data),
                                             data.get('source_id'))

Response: Deserialize a previously serialized object.


Instruction:
Can you implement a function in Python 3 that
connects securely and privately to the endpoint represented by the object.

Response:
async def connect(self, options: str) -> str:
        """
        Connect securely and privately to the endpoint represented by the object.

        :param options: detailed connection options
        Example options:
        {"connection_type":"SMS","phone":"5555555555","use_public_did":true}
        or:
        {"connection_type":"QR"}
        Example code:
        connection = await Connection.create('Sally')
        invite_details = await connection.connect('{"connection_type":"QR"}')
        :return: the invite details sent via SMS or ready to be sent via some other mechanism (QR for example)
        """
        if not hasattr(Connection.connect, "cb"):
            self.logger.debug("vcx_connection_connect: Creating callback")
            Connection.connect.cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32, c_char_p))

        c_connection_handle = c_uint32(self.handle)
        c_connection_data = c_char_p(options.encode('utf-8'))
        invite_details = await do_call('vcx_connection_connect',
                                       c_connection_handle,
                                       c_connection_data,
                                       Connection.connect.cb)
        return invite_details


Instruction:
Implement a Python 3 function for
sending a generic message to the connection.

Response:
async def send_message(self, msg: str, msg_type: str, msg_title: str) -> str:
        """
            Send a generic message to the connection
            :param msg:
            :param msg_type:
            :param msg_title:
            :return:
            """
        if not hasattr(Connection.send_message, "cb"):
            self.logger.debug("vcx_connection_send_message: Creating callback")
            Connection.send_message.cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32, c_char_p))

        c_connection_handle = c_uint32(self.handle)
        c_msg = c_char_p(msg.encode('utf-8'))
        c_msg_type = c_char_p(msg_type.encode('utf-8'))
        c_msg_title = c_char_p(msg_title.encode('utf-8'))

        result = await do_call('vcx_connection_send_message',
                               c_connection_handle,
                               c_msg,
                               c_msg_type,
                               c_msg_title,
                               Connection.send_message.cb)

        self.logger.debug("vcx_connection_send_message completed")
        return result


Instruction:
Make a summary of the following Python 3 code
async def sign_data(self, msg: bytes) -> bytes:

        def transform_cb(arr_ptr: POINTER(c_uint8), arr_len: c_uint32):
            return bytes(arr_ptr[:arr_len]),

        if not hasattr(Connection.sign_data, "cb"):
            self.logger.debug("vcx_connection_sign_data: Creating callback")
            Connection.sign_data.cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32, POINTER(c_uint8), c_uint32), transform_cb)

        c_connection_handle = c_uint32(self.handle)
        c_msg_len = c_uint32(len(msg))

        result = await do_call('vcx_connection_sign_data',
                               c_connection_handle,
                               msg,
                               c_msg_len,
                               Connection.sign_data.cb)

        self.logger.debug("vcx_connection_sign_data completed")
        return result

Response: Signs data using connection s pairwise key.


Instruction:
Can you generate the documentation for the following Python 3 function
async def verify_signature(self, msg: bytes, signature: bytes) -> bool:
        if not hasattr(Connection.verify_signature, "cb"):
            self.logger.debug("vcx_connection_verify_signature: Creating callback")
            Connection.verify_signature.cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32, c_bool))

        c_connection_handle = c_uint32(self.handle)
        c_msg_len = c_uint32(len(msg))
        c_signature_len = c_uint32(len(signature))

        result = await do_call('vcx_connection_verify_signature',
                               c_connection_handle,
                               msg,
                               c_msg_len,
                               signature,
                               c_signature_len,
                               Connection.verify_signature.cb)

        self.logger.debug("vcx_connection_verify_signature completed")
        return result

Response: Verify the signature of a message.


Instruction:
Create a Python 3 function to
get the invite details that were sent to the endpoint.

Response:
async def invite_details(self, abbreviated: bool) -> dict:
        """
        Get the invite details that were sent or can be sent to the endpoint.

        :param abbreviated: abbreviate invite details or not
        Example:
        phone_number = '8019119191'
        connection = await Connection.create('foobar123')
        invite_details = await connection.connect(phone_number)
        inivte_details_again = await connection.invite_details()
        :return: JSON of invite_details sent to connection
        """
        if not hasattr(Connection.invite_details, "cb"):
            self.logger.debug("vcx_connection_invite_details: Creating callback")
            Connection.invite_details.cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32, c_char_p))

        c_connection_handle = c_uint32(self.handle)
        c_abbreviated = c_bool(abbreviated)

        details = await do_call('vcx_connection_invite_details',
                                c_connection_handle,
                                c_abbreviated,
                                Connection.invite_details.cb)

        return json.loads(details.decode())


Instruction:
Given the following Python 3 function, write the documentation
async def create(source_id: str, proof_request: str):
        constructor_params = (source_id,)

        c_source_id = c_char_p(source_id.encode('utf-8'))
        c_proof_request = c_char_p(json.dumps(proof_request).encode('utf-8'))
        c_params = (c_source_id, c_proof_request, )

        return await DisclosedProof._create("vcx_disclosed_proof_create_with_request",
                                   constructor_params,
                                   c_params)

Response: Create a disclosed proof for fulfilling a corresponding proof request.


Instruction:
Explain what the following Python 3 code does
async def deserialize(data: dict):
        disclosed_proof = await DisclosedProof._deserialize("vcx_disclosed_proof_deserialize",
                                                      json.dumps(data),
                                                      data.get('data').get('source_id'))
        return disclosed_proof

Response: Deserialize a disclosed proof from a dict.


Instruction:
Explain what the following Python 3 code does
async def get_requests(connection: Connection) -> dict:
        if not hasattr(DisclosedProof.get_requests, "cb"):
            DisclosedProof.get_requests.cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32, c_char_p))

        c_connection_handle = c_uint32(connection.handle)

        data = await do_call('vcx_disclosed_proof_get_requests',
                      c_connection_handle,
                      DisclosedProof.get_requests.cb)

        return json.loads(data.decode())

Response: Get all requests associated with the connection


Instruction:
Implement a Python 3 function for
getting the credentials from a disclosed proof.

Response:
async def get_creds(self) -> dict:
        """
        Gets the credentials from a disclosed proof
        Example:
        msg_id = '1'
        phone_number = '8019119191'
        connection = await Connection.create(source_id)
        await connection.connect(phone_number)
        disclosed_proof = await DisclosedProof.create_with_msgid(source_id, connection, msg_id)
        creds = await disclosed_proof.get_creds()
        :return: credentials
        """
        if not hasattr(DisclosedProof.get_creds, "cb"):
            self.logger.debug("vcx_disclosed_proof_retrieve_credentials: Creating callback")
            DisclosedProof.get_creds.cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32, c_char_p))

        c_disclosed_proof_handle = c_uint32(self.handle)

        data = await do_call('vcx_disclosed_proof_retrieve_credentials',
                             c_disclosed_proof_handle,
                             DisclosedProof.get_creds.cb)
        return json.loads(data.decode())


Instruction:
Can you generate the documentation for the following Python 3 function
async def send_proof(self, connection: Connection):
        if not hasattr(DisclosedProof.send_proof, "cb"):
            self.logger.debug("vcx_disclosed_proof_send_proof: Creating callback")
            DisclosedProof.send_proof.cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32))

        c_disclosed_proof_handle = c_uint32(self.handle)
        c_connection_handle = c_uint32(connection.handle)

        await do_call('vcx_disclosed_proof_send_proof',
                      c_disclosed_proof_handle,
                      c_connection_handle,
                      DisclosedProof.send_proof.cb)

Response: Sends the proof to the Connection


Instruction:
Write a Python 3 script for
generating the proof for the selected credentials and self - attested attributes.

Response:
async def generate_proof(self, selected_creds: dict, self_attested_attrs: dict):
        """
        Generates the proof
        Example:
        msg_id = '1'
        phone_number = '8019119191'
        connection = await Connection.create(source_id)
        await connection.connect(phone_number)
        disclosed_proof = await DisclosedProof.create_with_msgid(source_id, connection, msg_id)
        await disclosed_proof.generate_proof({}, {})
        :param selected_creds: Credentials issued
        :param self_attested_attrs: Self Attested Attributes
        :return: None
        """
        if not hasattr(DisclosedProof.generate_proof, "cb"):
            self.logger.debug("vcx_disclosed_proof_generate_proof: Creating callback")
            DisclosedProof.generate_proof.cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32))

        c_disclosed_proof_handle = c_uint32(self.handle)
        c_selected_creds = c_char_p(json.dumps(selected_creds).encode('utf-8'))
        c_self_attested_attrs = c_char_p(json.dumps(self_attested_attrs).encode('utf-8'))

        await do_call('vcx_disclosed_proof_generate_proof',
                      c_disclosed_proof_handle,
                      c_selected_creds,
                      c_self_attested_attrs,
                      DisclosedProof.generate_proof.cb)


Instruction:
How would you explain what the following Python 3 function does
async def create_payment_address(wallet_handle: int,
                                 payment_method: str,
                                 config: str) -> str:
    """
     Create the payment address for specified payment method

     This method generates private part of payment address
     and stores it in a secure place. Ideally it should be
     secret in libindy wallet (see crypto module).

     Note that payment method should be able to resolve this
     secret by fully resolvable payment address format.

    :param wallet_handle: wallet handle (created by open_wallet).
    :param payment_method: Payment method to use (for example, 'sov').
    :param config: payment address config as json:
       {
         seed: <str>, // allows deterministic creation of payment address
       }
    :return: payment_address: public identifier of payment address in fully resolvable payment address format.
    """

    logger = logging.getLogger(__name__)
    logger.debug("create_payment_address: >>> wallet_handle: %r, payment_method: %r, config: %r",
                 wallet_handle,
                 payment_method,
                 config)

    if not hasattr(create_payment_address, "cb"):
        logger.debug("create_payment_address: Creating callback")
        create_payment_address.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p))

    c_wallet_handle = c_int32(wallet_handle)
    c_payment_method = c_char_p(payment_method.encode('utf-8'))
    config = c_char_p(config.encode('utf-8'))

    request_result = await do_call('indy_create_payment_address',
                                   c_wallet_handle,
                                   c_payment_method,
                                   config,
                                   create_payment_address.cb)

    res = request_result.decode()
    logger.debug("create_payment_address: <<< res: %r", res)
    return res

Response: Create payment address for specified payment method and config.


Instruction:
Make a summary of the following Python 3 code
async def build_get_payment_sources_request(wallet_handle: int,
                                            submitter_did: str,
                                            payment_address: str) -> (str, str):
    """
    Builds Indy request for getting sources list for payment address
    according to this payment method.

    :param wallet_handle: wallet handle (created by open_wallet).
    :param submitter_did : (Option) DID of request sender
    :param payment_address: target payment address
    :return: get_sources_txn_json: Indy request for getting sources list for payment address
             payment_method: used payment method
    """

    logger = logging.getLogger(__name__)
    logger.debug("build_get_payment_sources_request: >>> wallet_handle: %r, submitter_did: %r, payment_address: %r",
                 wallet_handle,
                 submitter_did,
                 payment_address)

    if not hasattr(build_get_payment_sources_request, "cb"):
        logger.debug("build_get_payment_sources_request: Creating callback")
        build_get_payment_sources_request.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p, c_char_p))

    c_wallet_handle = c_int32(wallet_handle)
    c_submitter_did = c_char_p(submitter_did.encode('utf-8')) if submitter_did is not None else None
    c_payment_address = c_char_p(payment_address.encode('utf-8'))

    (get_sources_txn_json, payment_method) = await do_call('indy_build_get_payment_sources_request',
                                                           c_wallet_handle,
                                                           c_submitter_did,
                                                           c_payment_address,
                                                           build_get_payment_sources_request.cb)
    res = (get_sources_txn_json.decode(), payment_method.decode())

    logger.debug("build_get_payment_sources_request: <<< res: %r", res)
    return res

Response: Builds get sources list request.


Instruction:
Can you generate a brief explanation for the following Python 3 code
async def build_payment_req(wallet_handle: int,
                            submitter_did: str,
                            inputs_json: str,
                            outputs_json: str,
                            extra: Optional[str]) -> (str, str):
    """
    Builds Indy request for doing payment
    according to this payment method.

    This method consumes set of inputs and outputs.

    Format of inputs is specific for payment method. Usually it should reference payment transaction
    with at least one output that corresponds to payment address that user owns.

    :param wallet_handle: wallet handle (created by open_wallet).
    :param submitter_did : (Option) DID of request sender
    :param inputs_json: The list of payment sources as json array:
      ["source1", ...]
      Note that each source should reference payment address
    :param outputs_json: The list of outputs as json array:
      [{
        recipient: <str>, // payment address of recipient
        amount: <int>, // amount
      }]
    :param extra: // optional information for payment operation

    :return: payment_req_json: Indy request for doing payment
             payment_method: used payment method
    """

    logger = logging.getLogger(__name__)
    logger.debug("build_payment_req: >>> wallet_handle: %r, submitter_did: %r, inputs_json: %r, outputs_json: %r,"
                 " extra: %r",
                 wallet_handle,
                 submitter_did,
                 inputs_json,
                 outputs_json,
                 extra)

    if not hasattr(build_payment_req, "cb"):
        logger.debug("build_payment_req: Creating callback")
        build_payment_req.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p, c_char_p))

    c_wallet_handle = c_int32(wallet_handle)
    c_submitter_did = c_char_p(submitter_did.encode('utf-8')) if submitter_did is not None else None
    c_inputs_json = c_char_p(inputs_json.encode('utf-8'))
    c_outputs_json = c_char_p(outputs_json.encode('utf-8'))
    c_extra = c_char_p(extra.encode('utf-8')) if extra is not None else None

    (payment_req_json, payment_method) = await do_call('indy_build_payment_req',
                                                       c_wallet_handle,
                                                       c_submitter_did,
                                                       c_inputs_json,
                                                       c_outputs_json,
                                                       c_extra,
                                                       build_payment_req.cb)
    res = (payment_req_json.decode(), payment_method.decode())

    logger.debug("build_payment_req: <<< res: %r", res)
    return res

Response: Builds Indy request for doing payment.


Instruction:
Write a Python 3 function for
building Indy request for setting fees for transactions in ledger.

Response:
async def build_set_txn_fees_req(wallet_handle: int,
                                 submitter_did: str,
                                 payment_method: str,
                                 fees_json: str) -> str:
    """
    Builds Indy request for setting fees for transactions in the ledger

    :param wallet_handle: wallet handle (created by open_wallet).
    :param submitter_did : (Option) DID of request sender
    :param payment_method: Payment method to use (for example, 'sov').
    :param fees_json: {
       txnType1: amount1,
       txnType2: amount2,
       .................
       txnTypeN: amountN,
     }
    :return: set_txn_fees_json: Indy request for setting fees for transactions in the ledger
    """

    logger = logging.getLogger(__name__)
    logger.debug("build_set_txn_fees_req: >>> wallet_handle: %r, submitter_did: %r, payment_method: %r, fees_json: %r",
                 wallet_handle,
                 submitter_did,
                 payment_method,
                 fees_json)

    if not hasattr(build_set_txn_fees_req, "cb"):
        logger.debug("build_set_txn_fees_req: Creating callback")
        build_set_txn_fees_req.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p))

    c_wallet_handle = c_int32(wallet_handle)
    c_submitter_did = c_char_p(submitter_did.encode('utf-8')) if submitter_did is not None else None
    c_payment_method = c_char_p(payment_method.encode('utf-8'))
    c_fees_json = c_char_p(fees_json.encode('utf-8'))

    set_txn_fees_json = await do_call('indy_build_set_txn_fees_req',
                                      c_wallet_handle,
                                      c_submitter_did,
                                      c_payment_method,
                                      c_fees_json,
                                      build_set_txn_fees_req.cb)

    res = set_txn_fees_json.decode()
    logger.debug("build_set_txn_fees_req: <<< res: %r", res)
    return res


Instruction:
Explain what the following Python 3 code does
async def build_get_txn_fees_req(wallet_handle: int,
                                 submitter_did: str,
                                 payment_method: str) -> str:
    """
    Builds Indy request for getting fees for transactions in the ledger

    :param wallet_handle: wallet handle (created by open_wallet).
    :param submitter_did : (Option) DID of request sender
    :param payment_method: Payment method to use (for example, 'sov').
    :return: set_txn_fees_json: Indy request for setting fees for transactions in the ledger
    """

    logger = logging.getLogger(__name__)
    logger.debug("build_get_txn_fees_req: >>> wallet_handle: %r, submitter_did: %r, payment_method: %r",
                 wallet_handle,
                 submitter_did,
                 payment_method)

    if not hasattr(build_get_txn_fees_req, "cb"):
        logger.debug("build_get_txn_fees_req: Creating callback")
        build_get_txn_fees_req.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p))

    c_wallet_handle = c_int32(wallet_handle)
    c_submitter_did = c_char_p(submitter_did.encode('utf-8')) if submitter_did is not None else None
    c_payment_method = c_char_p(payment_method.encode('utf-8'))

    get_txn_fees_json = await do_call('indy_build_get_txn_fees_req',
                                      c_wallet_handle,
                                      c_submitter_did,
                                      c_payment_method,
                                      build_get_txn_fees_req.cb)

    res = get_txn_fees_json.decode()
    logger.debug("build_get_txn_fees_req: <<< res: %r", res)
    return res

Response: Builds Indy request for getting fees for transactions in ledger.


Instruction:
How would you explain what the following Python 3 function does
async def parse_get_txn_fees_response(payment_method: str,
                                      resp_json: str) -> str:
    """
    Parses response for Indy request for getting fees

    :param payment_method: Payment method to use (for example, 'sov').
    :param resp_json: response for Indy request for getting fees
    :return: fees_json: {
       txnType1: amount1,
       txnType2: amount2,
       .................
       txnTypeN: amountN,
     }
    """

    logger = logging.getLogger(__name__)
    logger.debug("parse_get_txn_fees_response: >>> payment_method: %r, resp_json: %r",
                 payment_method,
                 resp_json)

    if not hasattr(parse_get_txn_fees_response, "cb"):
        logger.debug("parse_get_txn_fees_response: Creating callback")
        parse_get_txn_fees_response.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p))

    c_payment_method = c_char_p(payment_method.encode('utf-8'))
    c_resp_json = c_char_p(resp_json.encode('utf-8'))

    fees_json = await do_call('indy_parse_get_txn_fees_response',
                              c_payment_method,
                              c_resp_json,
                              parse_get_txn_fees_response.cb)

    res = fees_json.decode()
    logger.debug("parse_get_txn_fees_response: <<< res: %r", res)
    return res

Response: Parses response for Indy request for getting fees.


Instruction:
Create a Python 3 function for
building Indy request for information to verify the payment receipt for transactions in ledger .

Response:
async def build_verify_payment_req(wallet_handle: int,
                                   submitter_did: str,
                                   receipt: str) -> (str, str):
    """
    Builds Indy request for information to verify the payment receipt

    :param wallet_handle: wallet handle (created by open_wallet).
    :param submitter_did : (Option) DID of request sender
    :param receipt: payment receipt to verify

    :return: verify_txn_json: Indy request for verification receipt for transactions in the ledger
             payment_method: used payment method
    """

    logger = logging.getLogger(__name__)
    logger.debug("build_verify_payment_req: >>> wallet_handle: %r, submitter_did: %r, receipt: %r",
                 wallet_handle,
                 submitter_did,
                 receipt)

    if not hasattr(build_verify_payment_req, "cb"):
        logger.debug("build_verify_payment_req: Creating callback")
        build_verify_payment_req.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p, c_char_p))

    c_wallet_handle = c_int32(wallet_handle)
    c_submitter_did = c_char_p(submitter_did.encode('utf-8')) if submitter_did is not None else None
    c_receipt = c_char_p(receipt.encode('utf-8'))

    (verify_txn_json, payment_method) = await do_call('indy_build_verify_payment_req',
                                                      c_wallet_handle,
                                                      c_submitter_did,
                                                      c_receipt,
                                                      build_verify_payment_req.cb)
    res = (verify_txn_json.decode(), payment_method.decode())

    logger.debug("build_verify_payment_req: <<< res: %r", res)
    return res


Instruction:
Here you have a function in Python 3, explain what it does
async def create(source_id: str, name: str, version: str, attrs: list, payment_handle: int):
        constructor_params = (source_id, name, version, attrs)

        c_source_id = c_char_p(source_id.encode('utf-8'))
        c_name = c_char_p(name.encode('utf-8'))
        c_version = c_char_p(version.encode('utf-8'))
        c_schema_data = c_char_p(json.dumps(attrs).encode('utf-8'))
        c_payment = c_uint32(payment_handle)
        c_params = (c_source_id, c_name, c_version, c_schema_data, c_payment)

        schema = await Schema._create("vcx_schema_create", constructor_params, c_params)
        schema.schema_id = await schema.get_schema_id()
        return schema

Response: Creates a new schema object that is written to the ledger


Instruction:
Create a Python 3 function for
creating the object from a previously serialized object. :param data: The output of the "serialize" call Example: source_id = 'foobar123' name = 'Address Schema' version = '1.0' attrs = ['address', 'city', 'state'] payment_handle = 0 schema1 = await Schema.create(source_id, name, version, attrs, payment_handle) data1 = await schema1.serialize() :return: A re-instantiated object

Response:
async def deserialize(data: dict):
        """
        Create the object from a previously serialized object.

        :param data: The output of the "serialize" call
        Example:
        source_id = 'foobar123'
        name = 'Address Schema'
        version = '1.0'
        attrs = ['address', 'city', 'state']
        payment_handle = 0
        schema1 = await Schema.create(source_id, name, version, attrs, payment_handle)
        data1 = await schema1.serialize()
        :return: A re-instantiated object
        """
        try:
            # Todo: Find better way to access attr_names. Potential for issues.
            schema = await Schema._deserialize("vcx_schema_deserialize",
                                               json.dumps(data),
                                               data['data']['source_id'],
                                               data['data']['name'],
                                               data['data']['version'],
                                               data['data']['data'])

            schema.schema_id = await schema.get_schema_id()
            return schema
        except KeyError:
            raise VcxError(ErrorCode.InvalidSchema)


Instruction:
How would you explain what the following Python 3 function does
async def lookup(source_id: str, schema_id: str):
        try:
            schema = Schema(source_id, '', '', [])

            if not hasattr(Schema.lookup, "cb"):
                schema.logger.debug("vcx_schema_get_attributes: Creating callback")
                Schema.lookup.cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32, c_uint32, c_char_p))

            c_source_id = c_char_p(source_id.encode('utf-8'))
            c_schema_id = c_char_p(schema_id.encode('utf-8'))

            handle, data = await do_call('vcx_schema_get_attributes',
                                         c_source_id,
                                         c_schema_id,
                                         Schema.lookup.cb)
            schema.logger.debug("created schema object")

            schema_result = json.loads(data.decode())
            schema.attrs = schema_result['data']
            schema.name = schema_result['name']
            schema.version = schema_result['version']
            schema.handle = handle
            return schema
        except KeyError:
            raise VcxError(ErrorCode.InvalidSchema)

Response: Create a new schema object from an existing ledger schema.


Instruction:
Implement a function in Python 3 to
get the ledger ID of the object containing the object containing the schema ID

Response:
async def get_schema_id(self):
        """
        Get the ledger ID of the object

        Example:
        source_id = 'foobar123'
        name = 'Address Schema'
        version = '1.0'
        attrs = ['address', 'city', 'state']
        payment_handle = 0
        schema1 = await Schema.create(source_id, name, version, attrs, payment_handle)
        id1 = await schema.get_schema_id()
        :return: ID string
        """
        cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32, c_char_p))
        c_handle = c_uint32(self.handle)
        id = await do_call('vcx_schema_get_schema_id', c_handle, cb)
        return id.decode()


Instruction:
Can you generate a brief explanation for the following Python 3 code
async def is_pairwise_exists(wallet_handle: int,
                             their_did: str) -> bool:
    """
    Check if pairwise is exists.

    :param wallet_handle: wallet handler (created by open_wallet).
    :param their_did: encoded Did.
    :return: true - if pairwise is exists, false - otherwise
    """

    logger = logging.getLogger(__name__)
    logger.debug("is_pairwise_exists: >>> wallet_handle: %r, their_did: %r",
                 wallet_handle,
                 their_did)

    if not hasattr(is_pairwise_exists, "cb"):
        logger.debug("is_pairwise_exists: Creating callback")
        is_pairwise_exists.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_bool))

    c_wallet_handle = c_int32(wallet_handle)
    c_their_did = c_char_p(their_did.encode('utf-8'))

    res = await do_call('indy_is_pairwise_exists',
                        c_wallet_handle,
                        c_their_did,
                        is_pairwise_exists.cb)

    logger.debug("is_pairwise_exists: <<< res: %r", res)
    return res

Response: Check if pairwise is exists.


Instruction:
Explain what the following Python 3 code does
async def list_pairwise(wallet_handle: int) -> str:

    logger = logging.getLogger(__name__)
    logger.debug("list_pairwise: >>> wallet_handle: %r", wallet_handle)

    if not hasattr(list_pairwise, "cb"):
        logger.debug("list_pairwise: Creating callback")
        list_pairwise.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p))

    c_wallet_handle = c_int32(wallet_handle)

    pairwise_list = await do_call('indy_list_pairwise',
                                  c_wallet_handle,
                                  list_pairwise.cb)

    res = pairwise_list.decode()
    logger.debug("list_pairwise: <<< res: %r", res)
    return res

Response: Get list of saved pairwise.


Instruction:
Implement a function in Python 3 to
get pairwise information for specific their_did.

Response:
async def get_pairwise(wallet_handle: int,
                       their_did: str) -> None:
    """
    Gets pairwise information for specific their_did.

    :param wallet_handle: wallet handler (created by open_wallet).
    :param their_did: encoded Did
    :return: pairwise_info_json: did info associated with their did
    """

    logger = logging.getLogger(__name__)
    logger.debug("get_pairwise: >>> wallet_handle: %r, their_did: %r",
                 wallet_handle,
                 their_did)

    if not hasattr(get_pairwise, "cb"):
        logger.debug("get_pairwise: Creating callback")
        get_pairwise.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_char_p))

    c_wallet_handle = c_int32(wallet_handle)
    c_their_did = c_char_p(their_did.encode('utf-8'))

    pairwise_info_json = await do_call('indy_get_pairwise',
                                       c_wallet_handle,
                                       c_their_did,
                                       get_pairwise.cb)

    res = pairwise_info_json.decode()
    logger.debug("get_pairwise: <<< res: %r", res)
    return res


Instruction:
Explain what the following Python 3 code does
async def set_pairwise_metadata(wallet_handle: int,
                                their_did: str,
                                metadata: Optional[str]) -> None:
    """
    Save some data in the Wallet for pairwise associated with Did.

    :param wallet_handle: wallet handler (created by open_wallet).
    :param their_did: encoded DID
    :param metadata: some extra information for pairwise
    :return: Error code
    """

    logger = logging.getLogger(__name__)
    logger.debug("set_pairwise_metadata: >>> wallet_handle: %r, their_did: %r, metadata: %r",
                 wallet_handle,
                 their_did,
                 metadata)

    if not hasattr(set_pairwise_metadata, "cb"):
        logger.debug("set_pairwise_metadata: Creating callback")
        set_pairwise_metadata.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32))

    c_wallet_handle = c_int32(wallet_handle)
    c_their_did = c_char_p(their_did.encode('utf-8'))
    c_metadata = c_char_p(metadata.encode('utf-8')) if metadata is not None else None

    await do_call('indy_set_pairwise_metadata',
                  c_wallet_handle,
                  c_their_did,
                  c_metadata,
                  set_pairwise_metadata.cb)

    logger.debug("set_pairwise_metadata: <<<")

Response: Set some extra information for pairwise associated with Did.


Instruction:
Given the following Python 3 function, write the documentation
def print_log(value_color="", value_noncolor=""):
    HEADER = '\033[92m'
    ENDC = '\033[0m'
    print(HEADER + value_color + ENDC + str(value_noncolor))

Response: set the colors for text


Instruction:
How would you explain what the following Python 3 function does
def set_runtime_config(config: str):

    logger = logging.getLogger(__name__)
    logger.debug("set_runtime_config: >>> config: %r", config)

    c_config = c_char_p(config.encode('utf-8'))

    do_call_sync('indy_set_runtime_config',
                 c_config)

    logger.debug("set_runtime_config: <<<")

Response: Set libindy runtime configuration.


Instruction:
Explain what the following Python 3 code does
async def create(source_id: str, name: str, requested_attrs: list, revocation_interval: dict, requested_predicates: list = []):
        constructor_params = (source_id,)

        c_source_id = c_char_p(source_id.encode('utf-8'))
        c_name = c_char_p(name.encode('utf-8'))
        c_req_predicates = c_char_p(json.dumps(requested_predicates).encode('utf-8'))
        c_req_attrs = c_char_p(json.dumps(requested_attrs).encode('utf-8'))
        c_revocation_interval = c_char_p(json.dumps(revocation_interval).encode('utf-8'))
        c_params = (c_source_id, c_req_attrs, c_req_predicates, c_revocation_interval, c_name)

        return await Proof._create("vcx_proof_create",
                                   constructor_params,
                                   c_params)

Response: Creates a generic object containing the specified attributes and revocation intervals.


Instruction:
Can you generate the documentation for the following Python 3 function
async def deserialize(data: dict):
        return await Proof._deserialize("vcx_proof_deserialize",
                                        json.dumps(data),
                                        data.get('data').get('source_id'))

Response: Deserialize a Proof object.


Instruction:
Can you create a Python 3 function that
requests a new proof from the database.

Response:
async def request_proof(self, connection: Connection):
        """
        Example:
        connection = await Connection.create(source_id)
        await connection.connect(phone_number)
        name = "proof name"
        requested_attrs = [{"name": "age", "restrictions": [{"schema_id": "6XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"Faber Student Info", "schema_version":"1.0", "schema_issuer_did":"6XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"8XFh8yBzrpJQmNyZzgoTqB", "cred_def_id": "8XFh8yBzrpJQmNyZzgoTqB:3:CL:1766" }, { "schema_id": "5XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"BYU Student Info", "schema_version":"1.0", "schema_issuer_did":"5XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"66Fh8yBzrpJQmNyZzgoTqB", "cred_def_id": "66Fh8yBzrpJQmNyZzgoTqB:3:CL:1766" } ] }, { "name":"name", "restrictions": [ { "schema_id": "6XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"Faber Student Info", "schema_version":"1.0", "schema_issuer_did":"6XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"8XFh8yBzrpJQmNyZzgoTqB", "cred_def_id": "8XFh8yBzrpJQmNyZzgoTqB:3:CL:1766" }, { "schema_id": "5XFh8yBzrpJQmNyZzgoTqB:2:schema_name:0.0.11", "schema_name":"BYU Student Info", "schema_version":"1.0", "schema_issuer_did":"5XFh8yBzrpJQmNyZzgoTqB", "issuer_did":"66Fh8yBzrpJQmNyZzgoTqB", "cred_def_id": "66Fh8yBzrpJQmNyZzgoTqB:3:CL:1766"}]}]
        proof = await Proof.create(source_id, name, requested_attrs)
        await proof.request_proof(connection)
        :param connection: Connection
        :return:
        """
        if not hasattr(Proof.request_proof, "cb"):
            self.logger.debug("vcx_proof_send_request: Creating callback")
            Proof.request_proof.cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32))

        c_proof_handle = c_uint32(self.handle)
        c_connection_handle = c_uint32(connection.handle)

        await do_call('vcx_proof_send_request',
                      c_proof_handle,
                      c_connection_handle,
                      Proof.request_proof.cb)


Instruction:
Can you generate a brief explanation for the following Python 3 code
async def get_proof(self, connection: Connection) -> list:
        if not hasattr(Proof.get_proof, "cb"):
            self.logger.debug("vcx_get_proof: Creating callback")
            Proof.get_proof.cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32, c_uint32, c_char_p))

        c_proof_handle = c_uint32(self.handle)
        c_connection_handle = c_uint32(connection.handle)

        proof_state, proof = await do_call('vcx_get_proof',
                                           c_proof_handle,
                                           c_connection_handle,
                                           Proof.get_proof.cb)
        self.proof_state = proof_state
        return json.loads(proof.decode())

Response: Get the proof for the given connection.


Instruction:
Given the following Python 3 function, write the documentation
async def vcx_agent_provision(config: str) -> None:
    logger = logging.getLogger(__name__)

    if not hasattr(vcx_agent_provision, "cb"):
        logger.debug("vcx_agent_provision: Creating callback")
        vcx_agent_provision.cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32, c_char_p))

    c_config = c_char_p(config.encode('utf-8'))

    result = await do_call('vcx_agent_provision_async',
                           c_config,
                           vcx_agent_provision.cb)

    logger.debug("vcx_agent_provision completed")
    return result.decode()

Response: Provision an agent in the agency populate configuration and wallet for this agent.


Instruction:
Can you tell what is the following Python 3 function doing
async def vcx_ledger_get_fees() -> str:
    logger = logging.getLogger(__name__)

    if not hasattr(vcx_ledger_get_fees, "cb"):
        logger.debug("vcx_ledger_get_fees: Creating callback")
        vcx_ledger_get_fees.cb = create_cb(CFUNCTYPE(None, c_uint32))

    result = await do_call('vcx_ledger_get_fees',
                           vcx_ledger_get_fees.cb)

    logger.debug("vcx_ledger_get_fees completed")
    return result

Response: Get ledger fees from the sovrin network


Instruction:
Here you have a function in Python 3, explain what it does
async def vcx_messages_download(status: str = None, uids: str = None, pw_dids: str = None) -> str:
    logger = logging.getLogger(__name__)

    if not hasattr(vcx_messages_download, "cb"):
        logger.debug("vcx_messages_download: Creating callback")
        vcx_messages_download.cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32, c_char_p))

    if status:
        c_status = c_char_p(status.encode('utf-8'))
    else:
        c_status = None

    if uids:
        c_uids = c_char_p(uids.encode('utf-8'))
    else:
        c_uids = None

    if pw_dids:
        c_pw_dids = c_char_p(pw_dids.encode('utf-8'))
    else:
        c_pw_dids = None

    result = await do_call('vcx_messages_download',
                           c_status,
                           c_uids,
                           c_pw_dids,
                           vcx_messages_download.cb)

    logger.debug("vcx_messages_download completed")
    return result

Response: Retrieve messages from the specified connection


Instruction:
Create a Python 3 function for
updating the status of messages from the specified connection

Response:
async def vcx_messages_update_status(msg_json: str):
    """
    Update the status of messages from the specified connection
    :param msg_json:
    :return:
    """
    logger = logging.getLogger(__name__)

    if not hasattr(vcx_messages_update_status, "cb"):
        logger.debug("vcx_messages_update_status: Creating callback")
        vcx_messages_update_status.cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32))

    c_msg_json = c_char_p(msg_json.encode('utf-8'))
    c_status = c_char_p("MS-106".encode('utf-8'))

    result = await do_call('vcx_messages_update_status',
                           c_status,
                           c_msg_json,
                           vcx_messages_update_status.cb)

    logger.debug("vcx_messages_update_status completed")
    return result


Instruction:
Implement a function in Python 3 to
sign a message with a key.

Response:
async def crypto_sign(wallet_handle: int,
                      signer_vk: str,
                      msg: bytes) -> bytes:
    """
    Signs a message with a key.

    Note to use DID keys with this function you can call indy_key_for_did to get key id (verkey) for specific DID.

    :param wallet_handle: wallet handler (created by open_wallet).
    :param signer_vk:  id (verkey) of my key. The key must be created by calling create_key or create_and_store_my_did
    :param msg: a message to be signed
    :return: a signature string
    """

    logger = logging.getLogger(__name__)
    logger.debug("crypto_sign: >>> wallet_handle: %r, signer_vk: %r, msg: %r",
                 wallet_handle,
                 signer_vk,
                 msg)

    def transform_cb(arr_ptr: POINTER(c_uint8), arr_len: c_uint32):
        return bytes(arr_ptr[:arr_len]),

    if not hasattr(crypto_sign, "cb"):
        logger.debug("crypto_sign: Creating callback")
        crypto_sign.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, POINTER(c_uint8), c_uint32), transform_cb)

    c_wallet_handle = c_int32(wallet_handle)
    c_signer_vk = c_char_p(signer_vk.encode('utf-8'))
    c_msg_len = c_uint32(len(msg))

    signature = await do_call('indy_crypto_sign',
                              c_wallet_handle,
                              c_signer_vk,
                              msg,
                              c_msg_len,
                              crypto_sign.cb)

    logger.debug("crypto_sign: <<< res: %r", signature)
    return signature


Instruction:
Write a Python 3 script to
verify a message with a verkey.

Response:
async def crypto_verify(signer_vk: str,
                        msg: bytes,
                        signature: bytes) -> bool:
    """
    Verify a signature with a verkey.

    Note to use DID keys with this function you can call indy_key_for_did to get key id (verkey) for specific DID.

    :param signer_vk: verkey of signer of the message
    :param msg: message that has been signed
    :param signature: a signature to be verified
    :return: valid: true - if signature is valid, false - otherwise
    """

    logger = logging.getLogger(__name__)
    logger.debug("crypto_verify: >>> my_vk: %r, signed_msg: %r, signature: %r",
                 signer_vk,
                 msg,
                 signature)

    if not hasattr(crypto_verify, "cb"):
        logger.debug("crypto_verify: Creating callback")
        crypto_verify.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, c_bool))

    c_signer_vk = c_char_p(signer_vk.encode('utf-8'))
    c_msg_len = c_uint32(len(msg))
    c_signature_len = c_uint32(len(signature))

    res = await do_call('indy_crypto_verify',
                        c_signer_vk,
                        msg,
                        c_msg_len,
                        signature,
                        c_signature_len,
                        crypto_verify.cb)

    logger.debug("crypto_verify: <<< res: %r", res)
    return res


Instruction:
Can you tell what is the following Python 3 function doing
async def auth_crypt(wallet_handle: int,
                     sender_vk: str,
                     recipient_vk: str,
                     msg: bytes) -> bytes:
    """
    **** THIS FUNCTION WILL BE DEPRECATED USE pack_message INSTEAD ****

    Encrypt a message by authenticated-encryption scheme.

    Sender can encrypt a confidential message specifically for Recipient, using Sender's public key.
    Using Recipient's public key, Sender can compute a shared secret key.
    Using Sender's public key and his secret key, Recipient can compute the exact same shared secret key.
    That shared secret key can be used to verify that the encrypted message was not tampered with,
    before eventually decrypting it.

    Note to use DID keys with this function you can call indy_key_for_did to get key id (verkey)
    for specific DID.

    :param wallet_handle: wallet handler (created by open_wallet).
    :param sender_vk: id (verkey) of my key. The key must be created by calling indy_create_key or
    indy_create_and_store_my_did
    :param recipient_vk: id (verkey) of their key
    :param msg: a message to be signed
    :return: encrypted message as an array of bytes
    """

    logger = logging.getLogger(__name__)
    logger.debug("auth_crypt: >>> wallet_handle: %r,sender_vk: %r, recipient_vk: %r, msg: %r",
                 wallet_handle,
                 sender_vk,
                 recipient_vk,
                 msg)

    def transform_cb(arr_ptr: POINTER(c_uint8), arr_len: c_uint32):
        return bytes(arr_ptr[:arr_len]),

    if not hasattr(auth_crypt, "cb"):
        logger.debug("auth_crypt: Creating callback")
        auth_crypt.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, POINTER(c_uint8), c_uint32), transform_cb)

    c_wallet_handle = c_int32(wallet_handle)
    c_sender_vk = c_char_p(sender_vk.encode('utf-8'))
    c_recipient_vk = c_char_p(recipient_vk.encode('utf-8'))
    c_msg_len = c_uint32(len(msg))

    res = await do_call('indy_crypto_auth_crypt',
                        c_wallet_handle,
                        c_sender_vk,
                        c_recipient_vk,
                        msg,
                        c_msg_len,
                        auth_crypt.cb)

    logger.debug("auth_crypt: <<< res: %r", res)
    return res

Response: This function is used to encrypt a message using authenticated - encryption scheme.


Instruction:
Make a summary of the following Python 3 code
async def anon_crypt(recipient_vk: str,
                     msg: bytes) -> bytes:
    """
    Encrypts a message by anonymous-encryption scheme.

    Sealed boxes are designed to anonymously send messages to a Recipient given its public key.
    Only the Recipient can decrypt these messages, using its private key.
    While the Recipient can verify the integrity of the message, it cannot verify the identity of the Sender.

    Note to use DID keys with this function you can call key_for_did to get key id (verkey)
    for specific DID.

    Note: use pack_message function for A2A goals.

    :param recipient_vk: verkey of message recipient
    :param msg: a message to be signed
    :return: an encrypted message as an array of bytes
    """

    logger = logging.getLogger(__name__)
    logger.debug("anon_crypt: >>> recipient_vk: %r, msg: %r",
                 recipient_vk,
                 msg)

    def transform_cb(arr_ptr: POINTER(c_uint8), arr_len: c_uint32):
        return bytes(arr_ptr[:arr_len]),

    if not hasattr(anon_crypt, "cb"):
        logger.debug("anon_crypt: Creating callback")
        anon_crypt.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, POINTER(c_uint8), c_uint32), transform_cb)

    c_recipient_vk = c_char_p(recipient_vk.encode('utf-8'))
    c_msg_len = c_uint32(len(msg))

    encrypted_message = await do_call('indy_crypto_anon_crypt',
                                      c_recipient_vk,
                                      msg,
                                      c_msg_len,
                                      anon_crypt.cb)
    res = encrypted_message
    logger.debug("anon_crypt: <<< res: %r", res)
    return res

Response: Encrypts a message using anonymous - encryption scheme.


Instruction:
Here you have a function in Python 3, explain what it does
async def anon_decrypt(wallet_handle: int,
                       recipient_vk: str,
                       encrypted_msg: bytes) -> bytes:
    """
    Decrypts a message by anonymous-encryption scheme.

    Sealed boxes are designed to anonymously send messages to a Recipient given its public key.
    Only the Recipient can decrypt these messages, using its private key.
    While the Recipient can verify the integrity of the message, it cannot verify the identity of the Sender.

    Note to use DID keys with this function you can call key_for_did to get key id (verkey)
    for specific DID.

    Note: use unpack_message function for A2A goals.

    :param wallet_handle: wallet handler (created by open_wallet).
    :param recipient_vk: id (verkey) of my key. The key must be created by calling indy_create_key or create_and_store_my_did
    :param encrypted_msg: encrypted message
    :return: decrypted message as an array of bytes
    """

    logger = logging.getLogger(__name__)
    logger.debug("anon_decrypt: >>> wallet_handle: %r, recipient_vk: %r, encrypted_msg: %r",
                 wallet_handle,
                 recipient_vk,
                 encrypted_msg)

    def transform_cb(arr_ptr: POINTER(c_uint8), arr_len: c_uint32):
        return bytes(arr_ptr[:arr_len]),

    if not hasattr(anon_decrypt, "cb"):
        logger.debug("anon_decrypt: Creating callback")
        anon_decrypt.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, POINTER(c_uint8), c_uint32), transform_cb)

    c_wallet_handle = c_int32(wallet_handle)
    c_recipient_vk = c_char_p(recipient_vk.encode('utf-8'))
    c_encrypted_msg_len = c_uint32(len(encrypted_msg))
    decrypted_message = await do_call('indy_crypto_anon_decrypt',
                                      c_wallet_handle,
                                      c_recipient_vk,
                                      encrypted_msg,
                                      c_encrypted_msg_len,
                                      anon_decrypt.cb)

    logger.debug("crypto_box_seal_open: <<< res: %r", decrypted_message)
    return decrypted_message

Response: Decrypts a message using anonymous - encryption scheme.


Instruction:
Implement a Python 3 function for
packing a message into a JWE - like format.

Response:
async def pack_message(wallet_handle: int,
                       message: str,
                       recipient_verkeys: list,
                       sender_verkey: Optional[str]) -> bytes:
    """
    Packs a message by encrypting the message and serializes it in a JWE-like format (Experimental)

    Note to use DID keys with this function you can call did.key_for_did to get key id (verkey)
    for specific DID.

    #Params
    command_handle: command handle to map callback to user context.
    wallet_handle: wallet handler (created by open_wallet)
    message: the message being sent as a string. If it's JSON formatted it should be converted to a string
    recipient_verkeys: a list of Strings which are recipient verkeys
    sender_verkey: the sender's verkey as a string. -> When None is passed in this parameter, anoncrypt mode is used

    returns an Agent Wire Message format as a byte array. See HIPE 0028 for detailed formats
    """

    logger = logging.getLogger(__name__)
    logger.debug("pack_message: >>> wallet_handle: %r, message: %r, recipient_verkeys: %r, sender_verkey: %r",
                 wallet_handle,
                 message,
                 recipient_verkeys,
                 sender_verkey)

    def transform_cb(arr_ptr: POINTER(c_uint8), arr_len: c_uint32):
        return bytes(arr_ptr[:arr_len]),

    if not hasattr(pack_message, "cb"):
        logger.debug("pack_message: Creating callback")
        pack_message.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, POINTER(c_uint8), c_uint32), transform_cb)

    c_wallet_handle = c_int32(wallet_handle)
    msg_bytes = message.encode("utf-8")
    c_msg_len = c_uint32(len(msg_bytes))
    c_recipient_verkeys = c_char_p(json.dumps(recipient_verkeys).encode('utf-8'))
    c_sender_vk = c_char_p(sender_verkey.encode('utf-8')) if sender_verkey is not None else None
    res = await do_call('indy_pack_message',
                        c_wallet_handle,
                        msg_bytes,
                        c_msg_len,
                        c_recipient_verkeys,
                        c_sender_vk,
                        pack_message.cb)
    logger.debug("pack_message: <<< res: %r", res)
    return res


Instruction:
Explain what the following Python 3 code does
async def unpack_message(wallet_handle: int,
                         jwe: bytes) -> bytes:
    """
    Unpacks a JWE-like formatted message outputted by pack_message (Experimental)

    #Params
    command_handle: command handle to map callback to user context.
    wallet_handle: wallet handler (created by open_wallet)
    message: the output of a pack message

    #Returns -> See HIPE 0028 for details
    (Authcrypt mode)

    {
        "message": <decrypted message>,
        "recipient_verkey": <recipient verkey used to decrypt>,
        "sender_verkey": <sender verkey used to encrypt>
    }

    (Anoncrypt mode)

    {
        "message": <decrypted message>,
        "recipient_verkey": <recipient verkey used to decrypt>,
    }
    """

    logger = logging.getLogger(__name__)
    logger.debug("unpack_message: >>> wallet_handle: %r, jwe: %r",
                 wallet_handle,
                 jwe)

    def transform_cb(arr_ptr: POINTER(c_uint8), arr_len: c_uint32):
        return bytes(arr_ptr[:arr_len]),

    if not hasattr(unpack_message, "cb"):
        logger.debug("unpack_message: Creating callback")
        unpack_message.cb = create_cb(CFUNCTYPE(None, c_int32, c_int32, POINTER(c_uint8), c_uint32), transform_cb)

    c_wallet_handle = c_int32(wallet_handle)
    c_jwe_len = c_uint32(len(jwe))
    res = await do_call('indy_unpack_message',
                        c_wallet_handle,
                        jwe,
                        c_jwe_len,
                        unpack_message.cb)

    logger.debug("unpack_message: <<< res: %r", res)
    return res

Response: Unpacks a JWE - like formatted message outputted by pack_message.


Instruction:
Can you write a function in Python 3 where it
initializes VCX with config file.

Response:
async def vcx_init(config_path: str) -> None:
    """
    Initializes VCX with config file.
    :param config_path: String
    Example:
    await vcx_init('/home/username/vcxconfig.json')
    :return:
    """
    logger = logging.getLogger(__name__)

    if not hasattr(vcx_init, "cb"):
        logger.debug("vcx_init: Creating callback")
        vcx_init.cb = create_cb(CFUNCTYPE(None, c_uint32, c_uint32))

    c_config_path = c_char_p(config_path.encode('utf-8'))

    result = await do_call('vcx_init',
                           c_config_path,
                           vcx_init.cb)

    logger.debug("vcx_init completed")
    return result