This repository contains code to run an Adversarial-Crypto experiment on IBM Watson Machine Learning. This experiment performs adversarial training to learn trivial encryption functions. The model is based on the TensorFlow implementation and the 2016 paper "Learning to Protect Communications with Adversarial Neural Cryptography" by Abadi and Andersen.
This experiment creates and trains three neural networks, termed Alice, Bob, and Eve. Alice takes inputs in_m (message), in_k (key)
and outputs the ciphertext as a string. Bob takes inputs in_k, ciphertext
and tries to reconstruct the message. Eve is an adversarial network that takes the ciphertext as its input and also tries to reconstruct the message. The main function attempts to train these networks and then evaluates them, all on random plaintext and key values.
This repository was developed as part of the IBM Code Model Asset Exchange
Domain | Application | Industry | Framework | Training Data | Input Data Format |
---|---|---|---|---|---|
Security | Cryptography | General | TensorFlow | Randomly generated text | Text |
- Abadi & Andersen, Learning to Protect Communications with Adversarial Neural Cryptography, ,2016.
- TensorFlow implementation
Component | License | Link |
---|---|---|
This repository | Apache 2.0 | LICENSE |
Model Code (3rd party) | Apache 2.0 | TensorFlow Models |
- This experiment requires a provisioned instance of the IBM Watson Machine Learning service. If you don't have an instance yet, go to Watson Machine Learning in the IBM Cloud Catalog to create one.
- Create an IBM Cloud Object Storage account if you don't have one (https://www.ibm.com/cloud/storage)
- Create credentials for either reading and writing or just reading
- From the bluemix console page (https://console.bluemix.net/dashboard/apps/), choose Cloud Object Storage
- On the left side, click the service credentials
- Click on the
new credentials
button to create new credentials - In the 'Add New Credentials' popup, use this parameter
{"HMAC":true} in the
Add Inline Configuration...` - When you create the credentials, copy the
access_key_id
andsecret_access_key
values. - Make a note of the endpoint url
- On the left side of the window, click on
Endpoint
- Copy the relevant public or private endpoint. [I choose the us-geo private endpoint].
- On the left side of the window, click on
- In addition setup your AWS S3 command line which can be used to create buckets and/or add files to COS.
- Export AWS_ACCESS_KEY_ID with your COS
access_key_id
and AWS_SECRET_ACCESS_KEY with your COSsecret_access_key
- Export AWS_ACCESS_KEY_ID with your COS
- Install IBM Cloud CLI
- Log in using
bx login
orbx login --sso
if within IBM
- Log in using
- Install ML CLI Plugin
- After install, check if there is any plugins that need update
bx plugin update
- Make sure to set up the various environment variables correctly:
ML_INSTANCE
,ML_USERNAME
,ML_PASSWORD
,ML_ENV
- After install, check if there is any plugins that need update
The run.sh utility script will deploy the experiment to WML and execute the experiment as a training-run
run.sh
If you want to run this experiment using Fabric for Deep Learning (FFDL), You can simply clone the FfDL repository and follow the instructions over here to convert your training-runs.yml
into FfDL's specification.