> For the complete documentation index, see [llms.txt](https://superrman.gitbook.io/privacy-engine/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://superrman.gitbook.io/privacy-engine/readme.md).

# Introduction

## 🔐 Privacy Engine

#### Multi-Protocol Cryptographic Library

### Multi-Protocol Encryption Library

Cryptographic library supporting Starknet, X25519, and other protocols for secure multi-recipient messaging

***

## 🎯 What is Privacy Engine?

The **Privacy Engine** is a cryptographic library that enables secure multi-recipient messaging across multiple protocols including **Starknet** and **X25519**. It features signature-based encryption, double-wrapping security, and multi-recipient support with standard cryptographic primitives.

## ✨ Key Features

#### 👥 Multi-Recipient Encryption

Encrypt messages for multiple recipients simultaneously across different protocols with individual key wrapping.

#### 🔐 Signature-Based Encryption

Double-wrapping encryption using ECDSA signatures for security and wallet integration.

#### 🛡️ Double-Wrapping Security

Two-layer encryption: ECDH + AES-GCM inner layer, signature-derived key outer layer.

#### ⚡ WebAssembly Performance

Rust implementation compiled to WebAssembly for browser compatibility.

#### 🔑 Multi-Protocol Support

Built for multiple protocols including Starknet and X25519 with cryptographic operations and key recovery.

#### 🧪 Testing

Test suite with unit tests, performance benchmarks, and integration tests.

## 🚀 Quick Start

```rust
use privacy_engine::encrypt::encrypt_message;
use privacy_engine::types::{RecipientInfo, Protocol};

// Encrypt a message for multiple recipients across different protocols
let message = b"Hello, secure multi-recipient world!";
let recipients = vec![
    RecipientInfo {
        pubkey: starknet_user_pubkey,  // Vec<u8>
        protocol: Protocol::Starknet,
    },
    RecipientInfo {
        pubkey: x25519_user_pubkey,    // Vec<u8>
        protocol: Protocol::X25519,
    },
];

let result = encrypt_message(message, recipients)?;

// Decrypt using the appropriate protocol and private key
// For Starknet: use signature-based decryption
// For X25519: use standard ECDH decryption
```

## 📊 Protocol Comparison

| Protocol         | Curve       | Key Size | Signature | Key Recovery | Use Case               |
| ---------------- | ----------- | -------- | --------- | ------------ | ---------------------- |
| \*\*Starknet\*\* | Stark Curve | 32 bytes | ✅ ECDSA   | ✅ Yes        | Blockchain, ZK systems |
| \*\*X25519\*\*   | Curve25519  | 32 bytes | ❌ No      | ❌ No         | Standard key exchange  |

## 🔐 Signature-Based Encryption

#### Why Signature-Based Encryption?

The Privacy Engine implements **signature-based encryption** for several reasons:

1. **🔒 Enhanced Security**: Double-wrapping provides an additional layer of security beyond standard ECDH
2. **👛 Wallet Integration**: Seamlessly integrates with existing wallets without exposing private keys
3. **🛡️ Forward Secrecy**: Ephemeral keys ensure past communications remain secure even if long-term keys are compromised
4. **🔐 Authentication**: Signature verification ensures only the intended recipient can decrypt
5. **⚡ Performance**: Optimized cryptographic operations

## 🏗️ Encryption Architecture

```

┌─────────────────────────────────────────────────────────────┐
│                    Privacy Engine                           │
│                 Starknet Protocol                           │
├─────────────────────────────────────────────────────────────┤
│  ┌─────────────────┐    ┌─────────────────┐                │
│  │   encrypt.rs    │    │   decrypt.rs    │                │
│  │                 │    │                 │                │
│  │ • Multi-recipient│    │ • Signature-based│               │
│  │   encryption    │    │   decryption    │                │
│  │ • Double-wrapping│    │ • Key recovery  │                │
│  └─────────────────┘    └─────────────────┘                │
├─────────────────────────────────────────────────────────────┤
│                    Starknet Layer                          │
│  ┌─────────────────┐    ┌─────────────────┐                │
│  │   starknet.rs   │    │   Key Recovery  │                │
│  │                 │    │                 │                │
│  │ • ECDSA Signing │    │ • Public Key    │                │
│  │ • ECDH Exchange │    │   Recovery      │                │
│  │ • Curve Point   │    │ • Signature     │                │
│  │   Operations    │    │   Verification  │                │
│  └─────────────────┘    └─────────────────┘                │
├─────────────────────────────────────────────────────────────┤
│                    Cryptographic Primitives               │
│  ┌─────────────────┐    ┌─────────────────┐                │
│  │   AES-256-GCM   │    │   SHA-256       │                │
│  │                 │    │                 │                │
│  │ • Message       │    │ • Key Derivation│                │
│  │   Encryption    │    │ • Hashing       │                │
│  │ • Authentication│    │ • Integrity     │                │
│  └─────────────────┘    └─────────────────┘                │
└─────────────────────────────────────────────────────────────┘

```

## 🏗️ System Architecture

```

┌─────────────────────────────────────────────────────────────┐
│                    Privacy Engine                           │
├─────────────────────────────────────────────────────────────┤
│  ┌─────────────────┐    ┌─────────────────┐                │
│  │   encrypt.rs    │    │   decrypt.rs    │                │
│  │                 │    │                 │                │
│  │ • Message       │    │ • Key unwrapping│                │
│  │   encryption    │    │ • Message       │                │
│  │ • Key wrapping  │    │   decryption    │                │
│  └─────────────────┘    └─────────────────┘                │
├─────────────────────────────────────────────────────────────┤
│                    Protocol Layer                           │
│  ┌─────────────────┐    ┌─────────────────┐                │
│  │   Starknet      │    │     X25519      │                │
│  │   Protocol      │    │    Protocol     │                │
│  │                 │    │                 │                │
│  │ • ECDSA         │    │ • Diffie-Hellman│                │
│  │ • Key recovery  │    │ • Key agreement │                │
│  │ • Curve25519    │    │ • X25519 curve  │                │
│  └─────────────────┘    └─────────────────┘                │
├─────────────────────────────────────────────────────────────┤
│                    Core Types                               │
│  ┌─────────────────┐    ┌─────────────────┐                │
│  │   types.rs      │    │ traits/crypto.rs│                │
│  │                 │    │                 │                │
│  │ • EncryptResult │    │ • CryptoProtocol│                │
│  │ • RecipientInfo │    │   trait         │                │
│  │ • Protocol enum │    │ • Unified API   │                │
│  └─────────────────┘    └─────────────────┘                │
└─────────────────────────────────────────────────────────────┘

```

## 📚 Documentation Sections

🚀

#### Getting Started

Learn how to set up and use the Privacy Engine in your project with step-by-step guides.

[Get Started →](/privacy-engine/getting-started/getting-started.md)

🏗️

#### Architecture

Understand the design principles and cryptographic foundations of the system.

[Learn More →](/privacy-engine/architecture/architecture.md)

🔧

#### Protocols

Detailed documentation for supported cryptographic protocols and their implementations.

[Explore Protocols →](/privacy-engine/protocols/protocols.md)

💡

#### Examples

Practical examples and use cases demonstrating real-world applications.

[View Examples →](/privacy-engine/examples/examples.md)

📖

#### API Reference

Complete API documentation with detailed function references and examples.

[Browse API →](https://github.com/Goodness5/privacy-engine/blob/master/docs/api-reference.md)

🔒

#### Security

Security considerations and best practices for production deployments.

[Security Guide →](https://github.com/Goodness5/privacy-engine/blob/master/docs/security.md)

## ⚡ Performance Benchmarks

#### Protocol Performance Comparison

**Key Generation**

Starknet: \~2ms\
X25519: \~1ms

**Key Agreement**

Starknet: \~3ms\
X25519: \~2ms

**Message Encryption**

Both: \~1ms

**Multi-Recipient**

\~5ms per recipient

**WebAssembly Size**

\~500KB gzipped

**Memory Usage**

\~10MB typical

## 🎯 Use Cases

**💬 Secure Messaging**

Multi-recipient encrypted messaging with cross-protocol support.

**⛓️ Blockchain Integration**

Secure communication in blockchain applications and smart contracts.

**🔗 IoT Security**

Device-to-device encrypted communication for IoT networks.

**🎭 Zero-Knowledge Systems**

Privacy-preserving cryptographic applications and ZK proofs.

**🌐 Cross-Platform**

Interoperability between different cryptographic schemes and platforms.

**🔐 Enterprise Security**

Enterprise-grade encryption for sensitive data and communications.

## 🚀 Getting Started

#### Ready to Get Started?

Install Privacy Engine and start building secure, multi-protocol applications today.

[📖 Read Documentation](/privacy-engine/getting-started/getting-started.md)

[🐙 View on GitHub](https://github.com/your-repo/privacy-engine)

***

**Privacy Engine** - Secure, multi-protocol cryptographic communication for the modern web. 🔐✨

\ <br>

Rust Cryptography Blockchain Zero-Knowledge Security
