def get_user_nonce()

in src/local_gpu_verifier/src/verifier/cc_admin.py [0:0]


def get_user_nonce(arguments_as_dictionary: dict) -> str:
    """Method to get nonce from the input arguments or generate a random nonce"""
    nonce = ""

    if arguments_as_dictionary["test_no_gpu"]:
        nonce = BaseSettings.NONCE

    elif arguments_as_dictionary["nonce"]:
        nonce_from_args = arguments_as_dictionary["nonce"]
        info_log.info("Use the provided nonce for attestation: " + nonce_from_args)
        try:
            _ = CcAdminUtils.validate_and_extract_nonce(nonce_from_args)
            nonce = nonce_from_args
        except Error as e:
            info_log.error(e)
            nonce = ""

    if nonce == "":
        info_log.info("Generating random nonce in the local GPU Verifier ..")
        nonce = CcAdminUtils.generate_nonce(BaseSettings.SIZE_OF_NONCE_IN_BYTES).hex()

    return nonce