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

# L2PS Subnet Framework

> Layer 2 Privacy Subnets provide encrypted, private transactions on top of the public L1 blockchain with batch rollups and ZK proofs.

# L2PS (Layer 2 Privacy Subnet) Framework

L2PS is a privacy-preserving transaction layer that enables **encrypted transactions** on the Demos Network. Unlike public L1 transactions, L2PS transactions are encrypted client-side and only decrypted by authorized network participants.

## Key Features

<CardGroup cols={2}>
  <Card title="Client-Side Encryption" icon="lock">
    Transactions are encrypted with **AES-GCM** (32-byte key, 12-byte IV, authentication tag) in your browser before leaving your device.
  </Card>

  <Card title="Batch Rollups" icon="layer-group">
    Multiple L2PS transactions are bundled into a single L1 transaction per block.
  </Card>

  <Card title="ZK Proofs" icon="shield-check">
    **PLONK** zero-knowledge proofs verify batch validity without revealing content.
  </Card>

  <Card title="Authenticated History" icon="key">
    Only address owners can access their private transaction history via cryptographic signatures.
  </Card>
</CardGroup>

## How It Works

### Transaction Flow

<Steps>
  <Step title="Client Encrypts">
    Transaction is encrypted with the shared **AES-GCM** key (32 bytes) and IV (12 bytes) in the browser before transmission.
  </Step>

  <Step title="L2PS Node Decrypts">
    Node receives encrypted blob, decrypts, validates signature and balance.
  </Step>

  <Step title="Batch Aggregator">
    Bundles up to 10 transactions per L1 block with ZK proof.
  </Step>

  <Step title="L1 Submission">
    Single L1 batch transaction submitted to blockchain.
  </Step>
</Steps>

### Privacy Model

| Component          | L1 (Public)    | L2PS (Private)                  |
| ------------------ | -------------- | ------------------------------- |
| **Amount**         | Visible to all | Encrypted                       |
| **Recipient**      | Visible to all | Encrypted                       |
| **Sender**         | Visible to all | Visible (outer tx)              |
| **History Access** | Anyone         | Owner only (signature required) |

## Transaction Lifecycle

Every L2PS transaction progresses through three stages:

<Steps>
  <Step title="Executed" icon="bolt">
    **Instant** - Local node decrypts, validates against L1 state, reserves balance.
  </Step>

  <Step title="Batched" icon="box">
    **Per L1 block** - Transaction included in batch with ZK proof generated.
  </Step>

  <Step title="Confirmed" icon="check">
    **Final** - L1 block confirmed, transaction is immutable on blockchain.
  </Step>
</Steps>

## Transaction Fee

<Info>
  Each L2PS transaction costs **1 DEM**. This creates a deflationary mechanism while ensuring fair access to privacy features.
</Info>

## Architecture Components

| Component            | Description                                   |
| -------------------- | --------------------------------------------- |
| **L2PS Mempool**     | Separate storage for encrypted transactions   |
| **Batch Aggregator** | Bundles transactions per L1 block (max 10 tx) |
| **ZK Prover**        | Generates PLONK proofs for batch validity     |
| **L2PS Consensus**   | Applies GCR edits to L1 state                 |
| **Hash Service**     | Relays consolidated hashes to validators      |

## Network Participation

To participate in an L2PS network, nodes must:

1. Have the shared **AES-GCM key** (32 bytes / 64 hex chars) and **IV** (12 bytes / 24 hex chars)
2. Be configured with the correct **L2PS UID**
3. Store and sync the L2PS mempool with other participants

```json theme={null}
// L2PS Network Configuration
{
  "uid": "testnet_l2ps_001",
  "enabled": true,
  "keys": {
    "private_key_path": "data/l2ps/testnet_l2ps_001/private_key.txt",
    "iv_path": "data/l2ps/testnet_l2ps_001/iv.txt"
  }
}
```

## Next Steps

<CardGroup cols={3}>
  <Card title="Transaction Handling" icon="arrows-rotate" href="./how-are-l2ps-transactions-handled">
    Learn how L2PS transactions are processed
  </Card>

  <Card title="Quick Start" icon="rocket" href="./quickstart">
    Set up L2PS from scratch
  </Card>

  <Card title="POC App" icon="flask" href="https://github.com/kynesyslabs/l2ps-poc">
    Interactive demo app for testing L2PS
  </Card>
</CardGroup>
