> For the complete documentation index, see [llms.txt](https://docs.engma.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.engma.io/ravid/data-tunnels.md).

# Data Tunnels

Services are reachable only through authenticated channels, preventing unauthenticated scanning and external access.

| Property            | Traditional Network          | Enigma Tunnels                      |
| ------------------- | ---------------------------- | ----------------------------------- |
| **Discoverability** | Services announce themselves | Nothing visible until authenticated |
| **Routing**         | Stable paths, cacheable      | Paths change every epoch            |
| **Endpoints**       | Fixed IPs, known ports       | No exposed endpoints                |

The pseudocode below illustrates the high-level steps used to establish an authenticaed tunnel.

```angular-ts
// TUNNEL ESTABLISHMENT PSEUDOCODE

function establishTunnel(user, targetService):
    // Phase 1: Authentication (BEFORE any network access)
    identity = user.getCertificate()
    if not verifyIdentity(identity):
        return REJECT  // No unauthenticated access

    // Phase 2: Policy Check
    policy = controller.getPolicy(identity, targetService)
    if not policy.allows(identity, targetService):
        return UNAUTHORIZED

    // Phase 3: Route Calculation (epoch-dependent)
    currentEpoch = getCurrentEpoch()
    availableRouters = getRoutersForEpoch(currentEpoch)
    route = calculateRoute(user.location, targetService, availableRouters)

    // Phase 4: Session Key Derivation
    ephemeralKey = generateECDHKeyPair()
    sessionKeys = deriveSessionKeys(ephemeralKey, targetService.publicKey)

    // Phase 5: Encrypted Tunnel
    tunnel = createEncryptedChannel(route, sessionKeys)

    return tunnel

function onEpochBoundary(tunnel, newEpoch):
    // Route rotation without dropping connection
    newRoute = calculateRoute(tunnel.user, tunnel.service, newEpoch)
    tunnel.migrateRoute(newRoute)
    tunnel.rotateSessionKeys()  // Forward secrecy
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.engma.io/ravid/data-tunnels.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
