> ## Documentation Index
> Fetch the complete documentation index at: https://docs.inco.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Types

> Encrypted data types in the Inco Rust Crate

# Types

The Inco Lightning SDK provides encrypted types that serve as handles to encrypted values stored off-chain by the covalidator network.

## Euint128

Handle to an encrypted unsigned 128-bit integer.

```rust theme={null}
use inco_lightning::types::Euint128;

pub struct Euint128(pub u128);
```

The `Euint128` type represents a reference to an encrypted value, not the encrypted data itself. The actual encrypted data is stored and processed by the covalidator network.

## Ebool

Handle to an encrypted boolean value.

```rust theme={null}
use inco_lightning::types::Ebool;

pub struct Ebool(pub u128);
```

## Storing Handles

Handles are 16 bytes and can be stored directly in your account structs:

```rust theme={null}
#[account]
pub struct ConfidentialAccount {
    pub balance: Euint128,      // Handle to encrypted balance
    pub is_active: Ebool,       // Handle to encrypted boolean
}
```

<Note>
  Handles are deterministically derived from operations, so the same operation with the same inputs always produces the same handle.
</Note>

## Input Functions

Create encrypted values from client-encrypted ciphertext or plaintext.

| Function       | Description                                | Signature                                       |
| -------------- | ------------------------------------------ | ----------------------------------------------- |
| `new_euint128` | Create encrypted u128 from ciphertext      | `(CpiContext, Vec<u8>, u8) -> Result<Euint128>` |
| `new_ebool`    | Create encrypted bool from ciphertext      | `(CpiContext, Vec<u8>, u8) -> Result<Ebool>`    |
| `as_euint128`  | Convert plaintext u128 to encrypted handle | `(CpiContext, u128) -> Result<Euint128>`        |
| `as_ebool`     | Convert plaintext bool to encrypted handle | `(CpiContext, bool) -> Result<Ebool>`           |

### Example: Creating encrypted values

```rust theme={null}
pub fn deposit(
    ctx: Context<Deposit>,
    ciphertext: Vec<u8>,  // Client-encrypted amount
) -> Result<()> {
    // Create CPI context
    let cpi_ctx = CpiContext::new(
        ctx.accounts.inco_lightning_program.to_account_info(),
        Operation {
            signer: ctx.accounts.authority.to_account_info(),
        },
    );

    // Create encrypted handle from ciphertext
    let encrypted_amount: Euint128 = new_euint128(cpi_ctx, ciphertext, 0)?;

    // Store the handle
    ctx.accounts.vault.balance = encrypted_amount;

    Ok(())
}
```

<Note>
  The last parameter in input and operation calls identifies whether the left-hand side operand is ciphertext (`0`) or plaintext (`1`). Always pass `0` when working with encrypted handles.
</Note>
