Skip to main content

Mortgage Calculator

This example demonstrates how you can deploy a function that performs secure mortgage eligibility calculation. By using Cape, the model is protected because it can only be accessed within a secure enclave. The input data is also protected because it is encrypted prior to being uploaded, and is sent over TLS into the Cape enclave.

Code

Clone the capeprivacy/functions public repository:

git clone git@github.com:capeprivacy/functions.git

Navigate into the folder containing the code for the mortgage calculator function:

cd mortgage

Login

Log in to Cape using:

cape login

Which produces:

Your CLI confirmation code is: PTHZ-WJFJ
Visit this URL to complete the login process: https://login.capeprivacy.com/activate?user_code=PTHZ-WJFJ
Congratulations, you're all set!

Deploy

Deploy your function to Cape using:

cape deploy ./app

Which produces:

Deploying function to Cape ...
Success! Deployed function to Cape
Function Id ➜ iSKD5PhTjsympZebaBP4PQ
Function Checksum ➜ c1ca2ce6057bc9b7ffc3903ddce2f3a3cb6b87fea47af8dd870d89623c7ba44e

Run

Invoke your function using:

cape run 47KVugdSrbeAJ3QPTfqhwS -f input.mortgage.json

Where input.mortgage.json contains:

{ "salary": 100000, "amount": 500000, "down": 100000 }

Which produces:

Congratulations! You qualify for a mortgage.

Feel free to try with different inputs:

cape run iSKD5PhTjsympZebaBP4PQ '{ "salary": 70000, "amount": 5000000, "down": 1000 }'

Which produces:

You do not qualify for a mortgage. You need a down payment of at least 5 percent of the house cost.