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.


Clone the capeprivacy/functions public repository:

git clone

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

cd mortgage


Log in to Cape using:

cape login

Which produces:

Your CLI confirmation code is: PTHZ-WJFJ
Visit this URL to complete the login process:
Congratulations, you're all set!


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


Invoke your function using:

cape run 47KVugdSrbeAJ3QPTfqhwS -f

Where 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.


We are actively soliciting feedback from our beta. Please use this form to provide feedback.