kaizen-ai / kaizenflow

KaizenFlow is a framework for Bayesian reasoning and AI/ML stream computing
GNU General Public License v3.0
112 stars 76 forks source link

Encryption flow for models #270

Closed gpsaggese closed 1 year ago

gpsaggese commented 1 year ago

The flow I've used is described here https://docs.google.com/document/d/1BYkCQn-oSwc3ZGIy3-vAwdoO5LwhzYI78G59cLeFkRQ/edit#

These commands will be run with the python script inside the container on the fly. You can see Solidity linter to get an idea on how to create a container on the fly and run commands inside it but you will have to create a python script for the same. Once this python script is executed a new obfuscated file will be generated in the same directory.

# Install pyarmor.
sudo /bin/bash -c "(source /venv/bin/activate; pip install pyarmor)"

pyarmor obfuscate --restrict=0 --recursive dataflow_lemonade/pipelines/C8 --output dataflow_lemonade/pipelines/C8_new

Expanding the same python script, now you have to check whether the encrypted and unecrypted model works. For this you will run the below commands using the script.

(echo "from .pytransform import pyarmor_runtime; pyarmor_runtime()" >tmp; cat dataflow_lemonade/pipelines/C8_new/__init__.py >>tmp); mv tmp dataflow_lemonade/pipelines/C8_new/__init__.py

python -c "import dataflow_lemonade.pipelines.C8_new.C8a_pipeline as f; a = f.C8a_DagBuilder(); print(a)"

cp -r /data/saggese/src_vc/lemonade1/dataflow_lemonade/pipelines/C8_new /data/saggese/src/orange1/dataflow_orange/pipelines/C8

python -c "import dataflow_orange.pipelines.C8.C8a_pipeline as f; a = f.C8a_DagBuilder(); print(a)"

Refer the exact commands from the word doc.

Lets take one step at a time and keep expanding the objectives you have to achieve. As an example, first create a container on the fly and see if it works, then move to install the tool and obfuscating inside the same container and so on.

Clear out any doubts you have, even from the Solidity linter file too because if you have understand that file completely creating this one will be really easy. Instructions to run this file is in the Defi readme file.

gpsaggese commented 1 year ago

Assigning to @samarth9008 for outsourcing

gpsaggese commented 1 year ago

There is a reference script release_encrypted_model.sh

samarth9008 commented 1 year ago

@lokashrinav Are you free on Tuesday to have quick chat on this issue with me and @gpsaggese?

samarth9008 commented 1 year ago

@gpsaggese what time will suit you tomorrow to work on it? Since @lokashrinav is not responsive, we can re-route it to @KangmingL who is ready for his next issue.

gpsaggese commented 1 year ago

@samarth9008 I can do 11am. If it works put 45 mins on my calendar. Thx

samarth9008 commented 1 year ago

@KangmingL does 11 am tomorrow works for you?

KangmingL commented 1 year ago

@gpsaggese @samarth9008 Sure works for me.

samarth9008 commented 1 year ago

@KangmingL Specs have been updated.

samarth9008 commented 1 year ago

Close as completed.