Quickstart Guide
Get started with TERE quickly by building your first secure application. This guide will walk you through creating, deploying, and executing a simple application in a Trusted Execution Environment.
Prerequisites
Before you begin, make sure you have:
- Installed the TERE SDK and CLI (see the Installation Guide)
- Set up the local development environment or configured a cloud provider
- Authenticated with your API key
1. Initialize a New Project
First, let's create a new TERE project:
The tere init
command will create the basic project structure with the following files:
package.json
: Project configurationtere.config.js
: TERE-specific configurationsrc/index.ts
: Main entry point for your application
2. Write Your First Secure Function
Open the src/index.ts
file and replace its contents with the following code:
This code defines three functions:
- encryptMessage: Encrypts a message using AES-GCM and stores the encryption key
- decryptMessage: Decrypts a previously encrypted message
- computeSecurely: Performs a simple computation (for demonstration purposes)
3. Build Your Application
Build your application using the TERE CLI:
This will compile your TypeScript code and package it as a TERE script (.tere file) in the dist
directory.
4. Deploy Your Application
Now, deploy your application to a local development TEE:
The --dev
flag tells TERE to deploy to the local development environment. If you want to deploy to a cloud provider, you can specify the provider and configuration:
The deployment will output a script ID that you'll need for the next steps. It should look something like script_abc123
.
5. Execute Your Secure Functions
Now that your application is deployed, you can execute the functions in the secure environment:
6. Using the SDK in Your Application
Instead of using the CLI, you can also use the TERE SDK in your application code. Create a new file called client.ts
with the following content:
You can run this code with:
7. Understanding What's Happening
Let's break down what's happening in this example:
- 1
When you deploy your application, TERE provisions a Trusted Execution Environment (TEE) with hardware-backed security guarantees.
- 2
Your code runs in a secure enclave with memory encryption and integrity protection, ensuring that even the infrastructure provider cannot access your sensitive data.
- 3
Each execution generates an attestation report, which provides cryptographic evidence that your code is running in a genuine TEE with the expected security properties.
- 4
The state management API allows you to store and retrieve data securely within the TEE, with automatic encryption and access controls.
8. Next Steps
Now that you've created your first TERE application, you can:
- Explore the core concepts to deepen your understanding of TERE
- Learn about attestation for verifying the security of your applications
- Check out the API reference for detailed information on all available functions
- Try the example applications for more complex use cases