API Reference

MC2 Client provides a Python interface through the Python package, mc2client. See the Installation section for installation instructions. To use the Python package, we’ll need to import it.

 import mc2client as mc2

Global Configuration

mc2client.set_config(general_config=None)

Set the path to the config file. This function must be run before running anything else.

pathstr

Path to config file

general_configstr

The path to the config file. This return value is useful when we’re calling set_config() without a parameter – it enables the caller the retrieve the cached config_path

Cryptographic Utilities

mc2client.configure_job(config)

Attest all of the worker enclaves and give them the shared symmetric key.

mc2client.decrypt_data(encrypted_file, plaintext_file, enc_format)

Decrypt a file in a certain format

encrypted_filestr

Path to encrypted data to decrypt

plaintext_filestr

Path to decrypted data

enc_formatstr

The encryption format (i.e. sql for Opaque SQL or xgb for Secure XGBoost)

mc2client.encrypt_data(plaintext_file, encrypted_file, schema_file=None, enc_format='xgb')

Encrypt a file in a certain format

plaintext_filestr

Path to data to be encrypted

encrypted_filestr

Destination path of encrypted data

schema_filestr

Path to schema of data. Represented as comma separated column types. Necessary for Opaque SQL encryption format.

enc_formatstr

The format to use for encryption Input sql if running Opaque SQL or xgb if running Secure XGBoost

mc2client.generate_keypair(expiration=315360000)

Generate a new private key and certificate and save it to path specified by user in config YAML passed to set_config()

expirationint

Number of seconds from now after which the generated certificate should expire

mc2client.generate_symmetric_key()

Generate a new symmetric key and save it path specified by user in config YAML passed to set_config()

num_bytesint

Number of bytes for key

Cloud Management

mc2client.create_cluster()

Create a cluster

mc2client.create_container()

Create container in storage from configuration file

mc2client.create_resource_group()

Create a resource group

mc2client.create_storage()

Create storage from configuration file

mc2client.delete_cluster()

Delete a cluster

mc2client.delete_container()

Delete container in storage from configuration file

mc2client.delete_resource_group()

Delete a resource group

mc2client.delete_storage()

Delete storage from configuration file

mc2client.download_file(input_path, output_path, use_azure=True)

Download file from Azure storage or head node disk

input_pathstr

Path to input file

output_pathstr

Path to output file

mc2client.get_head_ip()

Get IP address of head node of created cluster

mc2client.get_worker_ips()

Get IP addresses of all worker nodes in created cluster

mc2client.upload_file(input_path, output_path, use_azure=True)

Upload file to Azure storage or disk of all cluster VMs

input_pathstr

Path to input file

output_pathstr

Path to output file