To run these functions with Cape, you need to first install the Cape CLI. Then you will have to # from Cape's website or using the CLI:
cape #
These examples can be also executed from Cape's SDKs: cape-js and pycape. If you execute these functions from one of the SDK, you will have to generate a personal access token. This can be done from Cape's website or from the CLI:
cape token create --name my-token --description 'for use in the javascript sdk'
A simple function that returns whatever you send it. Check out the folder echo to learn how to deploy this function. To invoke this function, you can run the following:
cape run capedocs/echo -f echo/input.echo.data
A simple function checking if your number is prime or not. Check out the folder isprime to learn how to deploy this function. To invoke this function, you can run the following:
cape run capedocs/isprime -f isprime/input.isprime.data
In this example, we show how to run a function requiring a dependency. The function simply returns the current time based on a specific timezone using the Pendulum library. To learn how to deploy this function, check out the folder pendulum. To invoke the function, invoke:
cape run capedocs/pendulum Europe/Paris
A simple example with numpy dependencies and using pycape and serdio.lift_io to handle automatic serialization/deserialization of Cape function input/outputs. You can learn how to deploy this function by checking the folder np-stats. You can run the function as follow after install installing in a virtual environment in np-stats/requirements.txt
:
export TOKEN=<YOUR TOKEN>
export FUNCTION_ID=capedocs/np-stats
python np-stats/run.py
Simulates a cybersecurity search function, where the IP addresses you are interested in need to remain private but the data/logs you are searching might be public. You can learn more about this function by checking the folder secure-search.
cape run capedocs/secure-search -f secure_search/input.search.data
Demos how a secure trusted execution environment like Cape can be leveraged in consensus in order to guarantee fairness. Details on how to run this example can be found here.
To learn more about the confidential hide-and-seek example, you can check the folder hide_and_seek.
This application is a mortgage calculator that computes if an applicant is eligible for a mortgage. To learn how to deploy this application, you can check out the folder mortgage. To call this function, you can run:
cape run capedocs/mortgage -f mortgage/input.mortgage.json
To learn how you can deploy and invoke an image classification model using the onnxruntime, you can check the capeprivacy/image-classification-onnx repository.
This example demonstrates how to deploy and invoke an image classification model with tflite. To learn how to deploy this application, you can check out the folder image-classification. To invoke the model, run:
cape run capedocs/image-recognition -f image_recognition/coffee.jpg
('Image Label is :', 'espresso', ', with Accuracy :', 84.38, '%.')
This example demonstrates how you can deploy and invoke a sentiment analysis model with tflite. To learn how to deploy this application, you can check out the folder sentiment_analysis. To invoke the model, simply run:
cape run capedocs/sentiment-analysis -f sentiment_analysis/input.pos.data
('The sentiment is: ', 'positive', ' with a probability of ', 78.08290123939514, '%.')
You can check the following examples to learn about how to deploying and invoke machine learning models with Scikit-Learn:
- credit_card_fraud_detection: performs secure inference to classify credit card transactions as fraudulent or legitimate.
- logistic_regression_sklearn: securely train an Sklearn logistic regression model on the breast cancer dataset.
- batch_training: shows how to perform batch training with Sklearn model.
This example shows you how you can run the Cape's confidential optical character recognition service from the SDKs: cape-js and pycape.
For this example, we will run the OCR on the PDF ./ocr/claude_shannon.pdf
.
From cape-js:
Before invoking the OCR, set the environment variable CAPE_AUTH_TOKEN
to your personal access token.
export CAPE_AUTH_TOKEN="your cape auth token"
To run the OCR from cape-js on the PDF, from the ocr folder, run:
node run_ocr.mjs
To encrypt the PDF with cape.encrypt, then invoke the OCR on the encrypted PDF, run:
node encrypt_run_ocr.mjs
From pycape:
Before invoking the OCR, set the environment variable CAPE_AUTH_TOKEN
to your personal access token.
export CAPE_AUTH_TOKEN="your cape auth token"
To run the OCR from pycape on the PDF, from the ocr folder, run:
python run_ocr.py
To encrypt the PDF with cape.encrypt, then invoke the OCR on the encrypted PDF, run:
python encrypt_run_ocr.py