Metadata-Version: 2.4
Name: cifer
Version: 1.0.41
Summary: Federated Learning and Fully Homomorphic Encryption
Home-page: https://github.com/cifer-ai/cifer
Author: Cifer.ai
Author-email: support@cifer.ai
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 5 - Production/Stable
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Security :: Cryptography
Classifier: Framework :: Flask
Classifier: Framework :: FastAPI
Classifier: Environment :: Console
Classifier: Topic :: System :: Distributed Computing
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy<3,>=1.26
Requires-Dist: requests<3,>=2.32
Requires-Dist: pandas<3.0,>=2.0
Requires-Dist: scikit-learn<2.0,>=1.3
Requires-Dist: tensorflow>=2.13
Requires-Dist: phe>=1.5
Requires-Dist: PyYAML>=6.0
Requires-Dist: typer>=0.12
Requires-Dist: rich>=13.7
Requires-Dist: websockets>=12
Requires-Dist: PyJWT>=2.8
Requires-Dist: pycryptodome>=3.20
Requires-Dist: python-dotenv>=1.0
Provides-Extra: server
Requires-Dist: grpcio>=1.60; extra == "server"
Requires-Dist: grpcio-reflection>=1.60; extra == "server"
Provides-Extra: vision
Requires-Dist: opencv-python; extra == "vision"
Requires-Dist: Pillow>=10.0; extra == "vision"
Provides-Extra: audio
Requires-Dist: librosa<1.0,>=0.10; extra == "audio"
Requires-Dist: torchaudio; extra == "audio"
Requires-Dist: pydub>=0.25; extra == "audio"
Provides-Extra: nlp
Requires-Dist: transformers>=4.40; extra == "nlp"
Requires-Dist: datasets; extra == "nlp"
Provides-Extra: graph
Requires-Dist: torch>=2.2; extra == "graph"
Requires-Dist: torch-geometric>=2.4; extra == "graph"
Requires-Dist: dgl; extra == "graph"
Provides-Extra: geo
Requires-Dist: geopandas; extra == "geo"
Provides-Extra: 3d
Requires-Dist: open3d; extra == "3d"
Provides-Extra: medical
Requires-Dist: pydicom; extra == "medical"
Provides-Extra: agent
Requires-Dist: fastapi<1.0,>=0.110; extra == "agent"
Requires-Dist: Flask<4.0,>=3.0; extra == "agent"
Requires-Dist: flask-cors<7.0,>=4.0; extra == "agent"
Requires-Dist: uvicorn>=0.29; extra == "agent"
Requires-Dist: redis>=5; extra == "agent"
Requires-Dist: keyring>=24; extra == "agent"
Requires-Dist: pydantic<3.0,>=2.0; extra == "agent"
Requires-Dist: cryptography<47,>=41; extra == "agent"
Requires-Dist: pyOpenSSL>=23; extra == "agent"
Provides-Extra: notebook
Requires-Dist: ipython>=8.12; extra == "notebook"
Requires-Dist: ipywidgets>=8.1; extra == "notebook"
Requires-Dist: nbclient>=0.9; extra == "notebook"
Requires-Dist: nbformat>=5.9; extra == "notebook"
Requires-Dist: notebook>=7.0; extra == "notebook"
Provides-Extra: dev
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: Sphinx<9,>=7.4; extra == "dev"
Requires-Dist: docutils<0.22,>=0.20; extra == "dev"
Requires-Dist: Cython<4,>=3.0; extra == "dev"
Provides-Extra: all
Requires-Dist: Cython<4,>=3.0; extra == "all"
Requires-Dist: Flask<4.0,>=3.0; extra == "all"
Requires-Dist: Pillow>=10.0; extra == "all"
Requires-Dist: Sphinx<9,>=7.4; extra == "all"
Requires-Dist: cryptography<47,>=41; extra == "all"
Requires-Dist: datasets; extra == "all"
Requires-Dist: dgl; extra == "all"
Requires-Dist: docutils<0.22,>=0.20; extra == "all"
Requires-Dist: fastapi<1.0,>=0.110; extra == "all"
Requires-Dist: flask-cors<7.0,>=4.0; extra == "all"
Requires-Dist: geopandas; extra == "all"
Requires-Dist: grpcio-reflection>=1.60; extra == "all"
Requires-Dist: grpcio>=1.60; extra == "all"
Requires-Dist: ipython>=8.12; extra == "all"
Requires-Dist: ipywidgets>=8.1; extra == "all"
Requires-Dist: keyring>=24; extra == "all"
Requires-Dist: librosa<1.0,>=0.10; extra == "all"
Requires-Dist: nbclient>=0.9; extra == "all"
Requires-Dist: nbformat>=5.9; extra == "all"
Requires-Dist: notebook>=7.0; extra == "all"
Requires-Dist: open3d; extra == "all"
Requires-Dist: opencv-python; extra == "all"
Requires-Dist: pyOpenSSL>=23; extra == "all"
Requires-Dist: pydantic<3.0,>=2.0; extra == "all"
Requires-Dist: pydicom; extra == "all"
Requires-Dist: pydub>=0.25; extra == "all"
Requires-Dist: pytest>=8.0; extra == "all"
Requires-Dist: redis>=5; extra == "all"
Requires-Dist: torch-geometric>=2.4; extra == "all"
Requires-Dist: torch>=2.2; extra == "all"
Requires-Dist: torchaudio; extra == "all"
Requires-Dist: transformers>=4.40; extra == "all"
Requires-Dist: uvicorn>=0.29; extra == "all"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

<p align="left">
  <a href="https://cifer.ai/">
    <img src="https://cifer.ai/assets/themes/cifer/images/logo/ciferlogo.png" width="240" alt="Cifer Website" />
  </a>
</p>

Cifer is a **Federated Learning framework with integrated Fully Homomorphic Encryption (FHE)** for secure, decentralized model training and encrypted aggregation.

It improves model robustness, reduces bias, and handles distribution shift across non-IID data.

Supports both centralized and decentralized topologies by default, with optional Cifer Blockchain integration for auditability and provenance.

[![GitHub license](https://img.shields.io/github/license/CiferAI/ciferai)](https://github.com/CiferAI/ciferai/blob/main/LICENSE)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/CiferAI/ciferai/blob/main/CONTRIBUTING.md)
[![Downloads](https://static.pepy.tech/badge/cifer)](https://pepy.tech/project/cifer)

[🌎 Website](https://cifer.ai) &nbsp;&nbsp;| &nbsp;
[📔 Docs](https://cifer.ai/documentation) &nbsp;&nbsp;| &nbsp;
[🙌 Join Slack](https://join.slack.com/t/cifertalk/shared_invite/zt-2y09cb0yu-zHYyNkiYWq6AfssvU2rLrA)

---
<br>

# Cifer Python Package (PyPI)

The cifer Python package provides a secure, programmatic interface for executing **Privacy-Preserving Machine Learning (PPML)** workflows. It enables local and distributed model training using **Federated Learning (FL)** and **Fully Homomorphic Encryption (FHE)**—without ever exposing raw data.

This package is ideal for Python developers, researchers, and data scientists who need fine-grained control over federated workflows within trusted or adversarial environments.

For alternative development workflows:

* Use the[ Cifer Python Package](https://pypi.org/project/cifer) for direct integration into custom Python-based ML pipelines
* Use[ Cifer Workspace](https://workspace.cifer.ai) for browser-based, no-code orchestration and collaborative workspace

---
<br>

# What is Cifer Federated Learning?

**Cifer Federated Learning (FedLearn)** is a secure training framework that enables collaborative machine learning across distributed data sources—without ever sharing raw data. Each participant (or node) performs local training, and only encrypted model updates are exchanged across the network.

Rather than centralizing data into a vulnerable repository, Cifer coordinates encrypted computations between participants, preserving **data sovereignty, compliance,** and **confidentiality** across jurisdictions and organizations.

## Key Extensions Beyond Standard FL

* **Fully Homomorphic Encryption (FHE)** \
  Cifer integrates FHE at the protocol level, allowing model updates and gradients to be computed on encrypted tensors. This ensures data remains encrypted throughout the lifecycle—including training, aggregation, and communication.\
  Unlike differential privacy (DP), which introduces noise and cannot fully prevent reconstruction attacks, FHE offers cryptographic guarantees against adversarial inference—even in hostile environments.

* **Dual Topology Support: Centralized and Decentralized** \
  Cifer supports both:
  * **Client–Server (cFL):** A central coordinator aggregates updates from authenticated participants—ideal for trusted, enterprise-level deployments.
  * **Peer-to-Peer (dFL):** Participants can operate without a central aggregator, enabling direct encrypted update exchanges across nodes for higher resilience.

* **Secure Communication Channels**\
  All communication is conducted over **gRPC**, leveraging **HTTP/2** and Protocol Buffers for efficient, multiplexed, and encrypted transport. This ensures fast synchronization while minimizing attack surfaces.

* **Blockchain Integration** (Optional)\
  For use cases requiring immutable audit trails, decentralized identity, or consensus-based coordination, Cifer supports integration with its proprietary **Cifer Blockchain Network**, providing an additional layer of provenance and tamper resistance.

## Federated Learning and the Adversarial Threat Model

Standard federated learning protocols are susceptible to:

* Gradient leakage and model inversion attacks
* Malicious participant injection
* Data reconstruction through side-channel inference

The industry trend has been to use differential privacy (DP) to mitigate these threats. However:

* DP requires complex tuning of privacy budgets (ε, δ)
* It introduces statistical noise, reducing model accuracy
* It provides probabilistic—not cryptographic—guarantees, and can still leak information under repeated queries or cumulative exposure


Cifer’s FHE-based design **eliminates these risks** by ensuring that all shared model artifacts remain mathematically unreadable, even under active attack or node compromise.

## Performance Capacity

Cifer FedLearn is built for real-world scale:

* Supports **client-server and P2P** topologies
* Tested for **model sizes and parameter transfers up to 30GB**
* Optimized for **GPU acceleration, NUMA-aware compute,** and **multi-node orchestration**

## Core Modules

* **FedLearn**\
  Orchestrates decentralized training across multiple nodes while maintaining data locality. Supports both:
  * **Centralized FL (cFL)** for governed, trusted environments
  * **Decentralized FL (dFL)** with peer coordination across encrypted channels
* **HomoCryption (FHE)**\
  Allows computation on encrypted data throughout the training lifecycle, preserving privacy even during intermediate operations.

## Key Capabilities

* **Hybrid Federation Support**\
  Choose between cFL or dFL architectures depending on governance, trust, and fault tolerance requirements.
* **Secure Communication Protocol**\
  Powered by gRPC with HTTP/2 and Protocol Buffers:
  * Low-latency streaming
  * Compact serialized messages
  * Built-in encryption and authentication
* **End-to-End Encrypted Computation**\
  FHE is embedded directly into the training workflow. No intermediate decryption. Data privacy is mathematically guaranteed.

---
<br>

# Before Getting Started

To ensure a smooth experience using Cifer for Federated Learning (FL) and Fully Homomorphic Encryption (FHE), please verify your system meets the following baseline requirements:

## System Requirements

* **Operating System**
  * Linux (Ubuntu 18.04 or later)
  * macOS (10.14 or later)
  * Windows 10 or later
* **Python**
  * Version: 3.9 (only version officially supported)
* **Memory**
  * Minimum: 8 GB RAM
  * Recommended: 16 GB+ for large-scale training or encryption tasks
* **Storage**
  * At least 30 GB of available disk space
* **Network**
  * Stable internet connection (required for remote collaboration or coordination modes)

## GPU Acceleration (Optional)

Cifer supports GPU acceleration for both FL and FHE components using:

* **NVIDIA CUDA** (for TensorFlow, PyTorch pipelines)
* **Google TPU** (via JAX and compatible backends)

While GPU is not mandatory, it is highly recommended for encrypted training at scale or production-grade deployments.

---
<br>

# Getting Started with Cifer’s Federated Learning

Cifer provides a modular Federated Learning (FL) framework that enables privacy-preserving model training across distributed environments. To get started, install the package via pip, import the required modules, and choose your preferred communication method for orchestration.

## What's Included in pip install cifer

Installing Cifer via pip provides the following components and features:

### **Core Modules**

* **FedLearn:** Federated learning engine for decentralized model training.
* **HomoCryption:** Fully Homomorphic Encryption (FHE) for computation on encrypted data.

**Integrations**

* **Built-in compatibility with** TensorFlo&#x77;**,** PyTorch, scikit-learn, NumPy, CUDA, JAX, Hugging Face Transformers.

**Utilities**

* Data preprocessing tools
* Privacy-preserving metrics
* Secure aggregation algorithms

**Cryptographic Libraries**

* Integration with advanced homomorphic encryption backends

**Communication Layer**

* gRPC-based secure communication protocols for FL orchestration

**Command-Line Interface (CLI)**

* CLI client for managing experiments and configurations

**Example Notebooks**

* Jupyter notebooks demonstrating end-to-end workflows

## **Optional Dependencies**

Install extras using:

```bash
pip install "cifer[server]"
```

Options:

* `server`: gRPC / WebSocket server dependencies
* `vision`: Vision-related helpers
* `audio`: Audio-related helpers
* `nlp`: Transformer-related helpers
* `graph`: Graph dataset / PyG helpers
* `geo`: Geospatial helpers
* `3d`: 3D helpers
* `medical`: Medical imaging helpers
* `agent`: API / agent runtime dependencies
* `notebook`: Jupyter and notebook tooling
* `dev`: test and documentation tooling
* `all`: Installs all optional dependencies

---
<br>

# 1. Install Cifer

```bash
pip install cifer
```

To include all optional features:

```bash
pip install "cifer[all]"
```

---
<br>

# 2. Quick Start

For the current package, the most reliable starting point is the CLI demo flow.

## Create a Project

```bash
cifer init my-cifer-project
```

This creates a local project skeleton with:

* `dataset/`
* `models/`
* `config.yaml`

## Create a Toy Dataset

```bash
cifer dataset toy --output demo_artifacts/toy_dataset.npz
```

## Run a One-Command Local Demo

```bash
cifer demo train --output-dir demo_artifacts --epochs 3
```

This command:

* creates a minimal `.npz` dataset
* creates a default `.keras` model
* trains locally and prints the final accuracy

---
<br>

# 3. Python API

The current Python API centers on `CiferClient`, `CiferServer`, and `securetrain`.

## Import Modules

```python
from cifer import CiferClient, CiferServer, CiferConfig
from cifer.securetrain import (
    generate_named_keys,
    encrypt_dataset,
    train_model,
    decrypt_dataset,
    decrypt_model,
)
```

## Dataset Format

For standard local training, `CiferClient` expects a `.npz` dataset containing:

* `train_images`
* `train_labels`

For graph workloads, use a `.pt` dataset instead.

## Local Client Example

```python
from cifer import CiferClient

client = CiferClient(
    encoded_project_id="YOUR_PROJECT_ID",
    encoded_company_id="YOUR_COMPANY_ID",
    encoded_client_id="YOUR_CLIENT_ID",
    base_api="https://workspace.cifer.ai/FederatedApi",
    dataset_path="dataset/toy_dataset.npz",
    model_path="models/toy_model.keras",
    use_encryption=False,
    epochs=3,
)

model, accuracy = client.train_model()
print("accuracy:", accuracy)
```

If `model_path` does not exist yet, Cifer will create a default Keras model automatically for standard `.npz` datasets.

---
<br>

# 4. CLI Commands

Common commands:

```bash
cifer version
cifer init my-project
cifer dataset toy --output demo_artifacts/toy_dataset.npz
cifer demo train --output-dir demo_artifacts --epochs 3
cifer client --dataset demo_artifacts/toy_dataset.npz --project-id ... --company-id ... --client-id ... --model-path demo_artifacts/toy_model.keras
cifer securetrain encrypt-dataset --dataset data.csv --output encrypted.json --key demo
```

Available command groups:

* `securetrain`
* `dataset`
* `demo`

Top-level commands include:

* `version`
* `init`
* `server`
* `client`
* `status`
* `register-kernel`
* `agent-ace`
* `download-notebook`

## Notes on Federated APIs

The package currently exposes:

* `CiferClient` for local training and upload flow
* `CiferServer` for aggregation/upload flow
* `run_federated_server(...)` for the lower-level runner

Older examples that reference `fl.Server()` or `fl.strategy.FedAvg(...)` do not match the current implementation and should not be used as the primary integration path.

---
<br>

# Getting Started with Cifer’s Homomorphic Encryption (FHE)

Cifer includes a built-in homocryption module for Fully Homomorphic Encryption (FHE), allowing computation on encrypted tensors without exposing raw data. You can encrypt, perform arithmetic, relinearize, and decrypt—all while preserving confidentiality.

## 1. Import HomoCryption Module

```python
from cifer.securetrain import (
   generate_named_keys,
   encrypt_dataset,
   train_model,
   decrypt_model,
)
```

## 2. Generate Keys

```python
from cifer.securetrain import generate_named_keys

generate_named_keys("demo")
```

## 3. Encrypt Data

```python
from cifer.securetrain import encrypt_dataset

encrypt_dataset("data.csv", "encrypted_dataset.json", "demo")
```

## 4. Perform Encrypted Computation

Train on encrypted data:

```python
from cifer.securetrain import train_model

train_model(
    encrypted_path="encrypted_dataset.json",
    output_model_path="encrypted_model.pkl",
    key_name="demo",
    feature_cols=["feature_a", "feature_b"],
    label_col="label",
)
```

Apply relinearization to manage ciphertext noise:

```bash
# Encrypt two vectors
vec1 = ts.ckks_vector(context, [1.0, 2.0, 3.0])
vec2 = ts.ckks_vector(context, [4.0, 5.0, 6.0])

# Multiply and relinearize
encrypted_result = vec1 * vec2
encrypted_result.relinearize()  # 👈 This is the relinearize step
decrypted = encrypted_result.decrypt()
```

## 5. Decrypt Result

```python
from cifer.securetrain import decrypt_dataset, decrypt_model

decrypt_dataset("encrypted_dataset.json", "decrypted_dataset.csv", "demo")
decrypt_model("encrypted_model.pkl", "decrypted_model.pkl", "demo")
```

| **Operation**  | **Method**         | **Compatible with Aggregation** |
| -------------- | ------------------ | ------------------------------- |
| Addition       | `hc.add()`         | ✅ Yes                           |
| Multiplication | `hc.mul()`         | ⚠️ Partially (check noise)      |
| Relinearize    | `hc.relinearize()` | ✅ Required after `mul()`        |
| Decryption     | `hc.decrypt()`     | 🔐 Private key required         |

---
<br>

# FHE in Aggregation Context

When using FHE-enabled federated learning:

* Each client encrypts model weights before sending
* The server performs aggregation (e.g., summing encrypted tensors)
* Final decryption happens at a trusted node after aggregation
* Only compatible operations (addition, averaging) are supported

> ⚠️ If FHE is enabled, make sure your aggregation strategy supports encrypted arithmetic.

---
<br>

# Learn More

For detailed examples, deployment patterns, and advanced configurations:

* Full documentation:[ https://www.cifer.ai/docs](https://www.cifer.ai/docs)
* GitHub repository:[ https://github.com/ciferai/cifer](https://github.com/ciferai/cifer)
* Developer support: support@cifer.ai


# Changelog
## [1.0.41] – 2026-05-18

### Changed
- Consolidated the network federated server into a single canonical implementation in `cifer.server`.
- Updated legacy `cifer.connection_handler` and `cifer.connection_handler_wss` imports to act as compatibility wrappers around the shared server path.
- Updated `cifer.fedlearn`, `cifer.run_federated_server()`, and the federated server example to use the canonical server implementation.

### Fixed
- Fixed NumPy 2 encrypted-weight unpickling compatibility by allowing the updated `numpy._core.multiarray._reconstruct` pickle path in the restricted unpickler.
- Added `pytest.ini` so `pytest` discovers the maintained `tests/` suite instead of collecting archived files under `_delete/`.

### Testing
- Verified `python3 -m pytest -q` with `23 passed`.
- Verified simple local training with `python3 -m cifer.cli demo train --output-dir demo_artifacts/test_simple_train --epochs 1`, producing `accuracy=0.7500`.

## [1.0.40] – 2026-04-28

### Added
- Added a shared federated core in `cifer/federated/` with `FederatedCoordinator`, `FedAvgStrategy`, and structured aggregation results.
- Added regression coverage for federated weight aggregation, shape-mismatch rejection, and coordinator-backed server aggregation.

### Changed
- Updated `CiferServer` to delegate model validation and FedAvg aggregation to the shared federated coordinator instead of keeping that logic inline.
- Updated the WebSocket and gRPC transport handlers to use the shared coordinator for aggregation instead of duplicating `numpy.mean(...)` aggregation logic in each transport path.

### Testing
- Verified the current package flow with `23 passed` across smoke and fixes test suites after the federated core refactor.

## [1.0.39] – 2026-04-20

### Changed
- Switched the default Keras model format from `.h5` to `.keras` across the package flow.
- Updated the client and config defaults so new local training runs create `.keras` models by default.

### Added
- Added `cifer dataset toy` to generate a minimal demo dataset.
- Added `cifer demo train` to create a toy dataset, build a default model, and train it in one command.
- Added smoke coverage for lazy imports and the new CLI demo flow.

### Fixed
- Refactored package imports to be lazy so `import cifer` no longer pulls heavy ML dependencies immediately.
- Fixed package installation flow by removing the broken post-install hook and aligning the `server` extra with the runtime import path.
- Fixed local model bootstrap so `CiferClient` can create and save a new model when the target model file does not exist yet.
- Fixed temporary API-loaded model handling to use the active Keras loader path consistently.

## [1.0.38] – 2026-04-08

### Fixed
- **CLI (`cli.py`):** Fixed incorrect `CiferServer` constructor call — was passing `host` and `port` which are not valid parameters. Now correctly passes `encoded_project_id`, `encoded_company_id`, `encoded_client_id`, `base_api`, and `dry_run`.
- **CLI (`cli.py`):** Fixed incorrect `CiferClient` constructor call — was passing `server_address` which is not a valid parameter. Now correctly passes all required fields including `dataset_path`, `model_path`, `use_encryption`, and `epochs`.
- **CLI (`cli.py`):** Fixed `securetrain encrypt-dataset`, `securetrain train`, and `securetrain decrypt-model` commands — were missing required `--key`, `--features`, and `--label` options that match the actual function signatures.
- **Security (`connection_handler.py`):** Removed hardcoded `SECRET_KEY = "your_jwt_secret_key"`. JWT secret is now loaded from the `CIFER_JWT_SECRET` environment variable. `FederatedServer` raises `RuntimeError` at instantiation if the variable is not set.
- **Client (`client.py`):** Fixed temporary file leak in `fetch_models_from_api()` — files created with `delete=False` are now cleaned up in a `finally` block via `os.unlink()`.
- **Server (`server.py`):** Fixed hardcoded `num_clients: 1` in `upload_aggregated_model()` — now reads the actual client count from `last_aggregation_summary` which is populated by `fed_avg()`.
- **Agent ACE (`agent_ace.py`):** Fixed malformed regex `r"^[^\\/\\\\]+\\.ipynb$"` — corrected to `r"^[^/\\]+\.ipynb$"` for proper `.ipynb` filename validation.
- **Securetrain (`securetrain.py`):** Replaced deprecated `DataFrame.applymap()` with `DataFrame.map()` for pandas compatibility.

### Security
- **Agent ACE (`agent_ace.py`):** Restricted CORS `allow_methods` from `["*"]` to `["GET", "POST"]` and `allow_headers` from `["*"]` to `["Authorization", "Content-Type"]`.

### Maintenance
- Moved unrelated and test files to `_delete/` folder for review: test scripts, log files, duplicate source files (`20260112__client.py`, `agent_ace_deleted.py`), loose documentation, and semgrep reports.

## [1.0.36] – 2026-03-17

### CLI
- Improved CLI output with rich formatting
- Enhanced command feedback and readability
- Added input validation for dataset and URL

### Server & Client
- Added better connection logs
- Improved error handling for server/client execution

### Secure Training
- Added validation for dataset and model paths
- Improved stability of encrypt/train/decrypt commands

### Dataset
- Improved dataset download reliability

### Improvements
- Improved config loading with fallback handling
- Added request timeout handling
- Reduced crash scenarios

### Internal
- Refactored CLI structure
- General code cleanup and stability improvements

[1.0.35] – 2026-03-09
## CLI
	• Improved CLI structure
	• Added commands: version, status, dataset download
	• Added notebook download command

## Secure Training
	• Added secure training commands for dataset encryption and model training

## Agent
	• Added ACE agent launcher

## Jupyter
	• Added Cifer kernel registration command

## Improvements
	• Improved config handling
	• Faster CLI startup with lazy imports

## Internal
	• Code refactoring and CLI cleanup


[1.0.34.1] – 2026-03-05
##  CLI
	•	Added new CLI system using Typer
	•	Added command: cifer init project
##  Fixes
	•	Fixed missing dependency typer
	•	Resolved Sphinx / docutils dependency conflict
	•	Fixed pip install cifer dependency issues
## Cleanup
	•	Cleaned requirements.txt
	•	Removed obsolete / Python2 packages
	•	Improved compatibility with Python 3.10+

[1.0.33] – 2026-02-23
##  Security
	•	Added WebSocket connection rate limiting (default: 5 connections / 10 seconds per IP).
	•	Added per-client message rate limiting (default: 20 messages / 5 seconds).
	•	Introduced custom WebSocket close codes:
	•	4008 – Connection rate exceeded.
	•	4009 – Message rate exceeded.
	•	Implemented in-memory sliding window limiter for lightweight protection.
	
##  Hardening
	•	Protected WebSocket server against connection flood attacks.
	•	Protected model submission endpoint from message spam/flood.
	•	Prevented uncontrolled reconnect spam during federated rounds.
## Testing
	•	Added test_connection_flood.py example script.
	•	Added test_message_flood.py example script.
	•	Verified close codes and limiter behavior under stress testing.

## [1.0.32] – 2026-02-17
## Improved
	•	Enforced secure 32-byte JWT secret with auto-generated .env.
	•	Fixed 1011 internal errors during aggregation.
	•	Added round timeout control and safer client disconnect handling.
	•	Implemented strict weight shape validation before aggregation.
	•	Limited WebSocket message size (10MB).
	•	Replaced prints with structured logging.
	•	Patched test client for secure JWT and clean connection handling.

## [1.0.31] – 2026-02-12
## Added
	•	Introduced Hybrid SaaS Agent (ACE v1.1) for secure cloud-controlled local execution.
	•	Added /run_notebook, /status/{execution_id}, /executions, and /health endpoints.
	•	Implemented per-project workspace isolation.
## Security
	•	Added optional Bearer token auth (CIFER_AGENT_TOKEN).
	•	Added CORS and notebook domain allowlist.
	•	Enforced .ipynb validation, timeout, and file size limits.

Improved
	•	Background notebook execution with status tracking.
	•	Decoupled agent from TensorFlow dependency for lightweight deployment.

## [1.0.30] – 2026-01-29
## Improved
	•	Improved package modularity by separating core dependencies from optional domain-specific features using extras_require.
	•	Reduced default installation footprint to support lightweight server-only and production deployments.
	•	Enhanced server readiness and operational stability in preparation for preflight checks and improved network resilience.
	•	Improved overall production usability and maintainability without introducing breaking changes or modifying existing aggregation logic.
### Notes
	•	This release focuses on packaging improvements and production hardening.
	•	Existing users can upgrade safely without changing their current workflows.
	•	Optional features can now be installed selectively via extras (e.g. cifer[vision], cifer[audio], cifer[all]).

## [1.0.29.1] – 2026-01-29
### Improved
	•	Added optional dry_run mode to the PPML server to allow aggregation and validation without uploading aggregated models.
	•	Introduced aggregation summary metadata (last_aggregation_summary) to support auditing, debugging, and future monitoring dashboards.
	•	Enhanced server observability with structured logging and execution-time metrics while preserving existing CLI output behavior.
	•	Improved internal extensibility by isolating additive capabilities without modifying existing aggregation or upload logic.

## [1.0.29] – 2026-01-29
### Improved
	•	Added structured logging and execution-time metrics to the PPML server for better observability and performance monitoring.
	•	Enhanced server reliability and audit readiness without changing existing aggregation logic or client behavior.

## [1.0.28] – 2026-01-19
### Improved
	•	Improved PPML server aggregation performance by eliminating unnecessary disk I/O and loading client models directly from memory during aggregation.
	•	Fixed server-side FedAvg invocation to correctly aggregate multiple client models without nested list errors.
	•	Added strict server-side validation for model layer count and weight shape compatibility to prevent silent aggregation failures.
	•	Enhanced robustness of server execution by failing early on invalid or incompatible client models.
	•	Reduced server–client coupling by isolating server functionality from client-side dependencies, enabling independent server execution and testing.

## [1.0.27] - 2026-01-11
###  Improved
	•	Added structured logging across the client lifecycle to improve observability, debugging, and audit readiness.
	•	Introduced dataset validation to ensure required training data keys and shape consistency before training.
	•	Enhanced error reporting for dataset loading, model training, aggregation, and API communication without altering existing logic.
	•	Improved runtime stability by failing early on invalid datasets, model shape mismatches, and missing resources.
	•	Strengthened production readiness while preserving backward compatibility and experimental feature support.

## [1.0.26] - 2026-01-05
### Improved
	•	Improved server-side network performance by reusing HTTP connections with `requests.Session`.
	•	Added configurable request timeouts to prevent stalled API calls during federated aggregation.
	•	Enhanced API error handling by failing fast on HTTP errors for more predictable server behavior.
	•	Increased stability and reliability of server-to-API communication without changing aggregation logic.
	
## [1.0.25] - 2025-12-15
### Fixed
	•	Fixed issues caused by emojis and decorative icons in CLI outputs that could break plain-text or non-Unicode environments.
	•	Resolved inconsistencies in CLI help texts and status messages.
### Improved
	•	Improved CLI output performance by simplifying message formatting.
	•	Enhanced clarity and reliability of error handling and status reporting.
	•	Reduced unnecessary output complexity to make CLI responses faster and more predictable.

## [1.0.24] - 2025-09-21
### Fixed
- Removed all emojis/icons from CLI help texts and outputs to ensure compatibility with plain-text environments.  
- Simplified output messages for clearer error handling and status reporting.  

### Improved
- Refactored CLI code for better readability by organizing commands into clear sections (Securetrain, Kernel, Agent, Notebook, Sync, Training Simulation).  
- Added structured comments and standardized indentation/spacing.  
- Renamed variables (e.g., `r` → `response` in `requests.get`) for clarity.  

## [1.0.23] - 2025-08-09
### Fixed
- Resolved build and package verification issues by ensuring `setuptools`, `wheel`, and `twine` are properly installed within a virtual environment (venv).
- Addressed installation restrictions on macOS caused by the `externally-managed-environment` limitation.

### Improved
- Enhanced documentation and workflow for publishing the package to PyPI.
- Improved pre-upload validation by integrating `twine check` to prevent errors before release.


## [1.0.22] - 2025-08-06
### Improved
- Refactored `FederatedServer` codebase to support dual communication protocols (WebSocket + gRPC) for more flexible federated learning setups.
- Enhanced CLI experience: users can now run `securetrain` commands directly (e.g., `cifer securetrain train`) without needing to call Python functions manually after installing via `pip install cifer`.

### Fixed
- General bug fixes and performance improvements.



## [1.0.16]-[1.0.17] - 2025-06-01
### Fixed
- Resolved ASGI app load error by specifying correct module path: `cifer.agent_ace:app`.

### Changed
- Updated `uvicorn.run()` in `run_agent_ace()` to use proper module path for FastAPI app loading.

### Added
- Verified kernel registration for `cifer-kernel`.
- Fu


## [1.0.15] - 2025-05-31

### ✅ **[Improved] FastAPI Migration**
* Migrated from Flask to **FastAPI** for the `/run_notebook` agent endpoint.
* Enhanced performance and scalability using `uvicorn` ASGI server.
* Full CORS middleware support added via FastAPI's built-in capabilities.
* Swagger/OpenAPI docs now available at `/docs`.

### ✅ **[Fixed] Python Compatibility & Kernel Registration**
* Improved `ensure_kernel_registered()` logic to use the current `sys.executable` Python version.
* Fixed Python version enforcement in `setup.py` (`python_requires=">=3.9"`).
* Added compatibility checks for Jupyter kernel auto-registration.
* Improved fallback behavior if `notebookapp` fails to resolve current Jupyter directory.

### ✅ **[New] Dependencies and PyPI Metadata**
* Added missing dependencies: `fastapi`, `scikit-learn`, `joblib`, `phe`.
* Validated compatibility with Python 3.10 and 3.11.
* Updated `setup.py` to support PyPI publishing with long description and entry point.


## \[1.0.14] - 2025-05-30

### ✅ **\[New] Cifer CLI Agent & Kernel Integration**
* Added `cifer` CLI with subcommands:
  * `agent-ace` – Run Flask server to download & execute Jupyter Notebooks
  * `register-kernel` – Automatically register Jupyter kernel for current Conda environment
  * `download-notebook`, `sync`, and `train` – Utility commands for notebook management and testing
* Introduced auto-registration for **🧠 Cifer AI Kernel** (`cifer-kernel`) on all CLI usage
* Executed notebooks are now forced to run using the `cifer-kernel` for consistent environment behavior
* Flask agent `/run_notebook` endpoint downloads, executes, and opens notebooks inside Jupyter


## [1.0.13] - 2025-05-10

### ✅ **\[New] Homomorphic Encryption (HE) Support**

* Added `use_encryption=True` flag in both `CiferClient` and `CiferServer`
* Integrated `Paillier` encryption using the `phe` library to secure model weights
* Client now generates a keypair (`public_key`, `private_key`) and encrypts weights before upload
* Encrypted model weights are uploaded via the new `/upload_encrypted_model` API

---

### ✅ **\[New] Server-Side Encrypted Model Aggregation**

* Added `fetch_encrypted_models()` to retrieve encrypted weights from clients
* Implemented `encrypted_fed_avg()` to perform homomorphic FedAvg without decrypting
* Encrypted aggregation output is saved as `aggregated_encrypted_weights.pkl` for client-side decryption

---

### ✅ **\[New] PHP/CodeIgniter API Enhancements**

* Added new API endpoint: `get_encrypted_client_models($project_id)` to fetch encrypted models only
* Validates and stores encrypted models in the `model_updates` table
* Automatically updates the project status to "Testing in Progress" when a model is uploaded

---

### ✅ **\[Fixes] Server Run Script Improvements**

* Automatically creates `model_path` and `dataset_path` if not present
* Added `USE_ENCRYPTION` flag in the run script to easily toggle encryption mode

---

### ⚙️ **Dependencies**

* `phe>=1.5.0` for Paillier homomorphic encryption
* `tensorflow>=2.0`, `numpy>=1.19`

## [1.0.8] - 2025-04-11
### Added
- ✨ Integrated `flask-cors` to support browser-based communication with the local Agent
- 🌐 Added support for launching Jupyter notebooks via either `localhost` or a remote `open_url`
- 📦 Included JavaScript client snippet for calling the agent directly from a web page
- 🧪 Added support for Homomorphic Encryption workflows in the agent-client pipeline

### Improved
- 🧠 Refactored agent logic to dynamically handle notebook URLs and browser launch targets
- 🔐 Enhanced agent's compatibility with encrypted notebook execution scenarios using homomorphic encryption
- 📁 Improved compatibility with both local Jupyter and server-proxied environments (e.g., `/notebook` on `workspace.cifer.ai`)

### Fixed
- ✅ Corrected hardcoded browser path (`/notebooks/notebooks/filename`) to proper rendering path
## [1.0.6] - 2025-03-23
### Fixed
- 🛠️ Resolved bug in data processing related to incorrect input handling.
- ✅ Improved error handling for missing or corrupted dataset files.
- ⚡ Optimized model loading process to prevent `AttributeError` in `CiferClient`.
- 🔐 Fixed issue where encrypted parameters were not being properly decrypted:

## [1.0.4] - 2025-03-17
### Fixed
- 🛠️ Resolved bug in data processing related to incorrect input handling.
- ✅ Improved error handling for missing or corrupted dataset files.
- ⚡ Optimized model loading process to prevent `AttributeError` in `CiferClient`.

## [1.0.3] - 2025-03-11
### Fixed
- Resolved bug in data processing related to incorrect input handling.
- Added WebSocket connectivity improvements to enhance stability and performance.


## [1.0.2] - 2025-03-09
### Fixed
- Resolved bug in data processing related to incorrect input handling.

## [1.0.1] - 2025-03-07
### Added
- Initial release of `cifer`
- Implements Homomorphic Encryption (LightPHE)
- API Server integration with Flask and Uvicorn

## [0.1.26] - 2024-10-28
### Added
- Websocket server-client 
- PyJWT
### Fixed
- Resolved bug in data processing related to incorrect input handling.

## [0.1.26] - 2024-10-28
### Added
- Added support for WebSocket Secure (WSS), allowing users to choose between standard WebSocket (WS) or secure WSS communication.
- Enabled model weight encryption using Homomorphic Encryption (RSA) for secure data transmission between Client and Server. This can be enabled with the use_homomorphic parameter.
- Added JSON Web Token (JWT) authentication, requiring Clients to send a token to the Server for identity verification, enhancing access control.
### Fixed
- Resolved import issues by switching to absolute imports in connection_handler.py to reduce cross-package import conflicts when running the project externally.

## [0.1.23] - 2024-10-22
### Fixed
- Resolved bug in data processing related to incorrect input handling.

## [0.1.22] - 2024-10-05
### Fixed
- No matching distribution found for tensorflow
- Package versions have conflicting dependencies.

## [0.1.19] - 2024-09-29
### Added
- Add conditional TensorFlow installation based on platform
### Fixed
- Resolved bug in data processing related to incorrect input handling.

## [0.1.18] - 2024-09-29
### Added
- Initial release of `FedServer` class that supports federated learning using gRPC.
- Added client registration functionality with `clientRegister`.
- Added model training round management with `startServer` function.
- Implemented federated averaging (FedAvg) aggregation for model weights.
- Model validation functionality with `__callModelValidation` method.
- Support for handling multiple clients concurrently with threading.
- Configurable server via `config.json`.

### Changed
- Modularized the code for future extension and improvement.
- Created configuration options for server IP, port, and `max_receive_message_length` via the `config.json` file.

### Fixed
- Optimized client handling to prevent blocking during registration and learning rounds.


## [0.1.15-0.1.17] - 2024-09-14
### Fixed
- Resolved bug in data processing related to incorrect input handling.

## [0.1.14] - 2024-09-013
### Fixed
- Resolved bug in data processing related to incorrect input handling.

## [0.1.13] - 2024-09-08
### Added
-- Integrate Tensorflow and Huggingface's Transformer
New Integration: Added support for TensorFlow and HuggingFace's Transformers library to enhance model training and expand compatibility with popular AI frameworks.
### Fixed
-- Resolved various bugs to improve system stability and performance.
This update continues to build on CiferAI's federated learning and fully homomorphic encryption (FHE) framework, focusing on enhanced compatibility, privacy, and security in decentralized machine learning environments.

## [0.1.11] - 2024-09-08
### Changed
- Homepage --- cifer.ai
Documentation. --- cifer.ai/documentation
Repository --- https://github.com/CiferAI/ciferai

## [0.1.10] - 2024-09-08
### Changed
- Updated `README.md` to improve content and information about Cifer.

## [0.0.9] - 2024-09-01
### Added
- Added new feature for handling exceptions in the main module.
- Included additional error logging functionality.

## [0.0.8] - 2024-08-25
### Fixed
- Resolved bug in data processing related to incorrect input handling.
