Skip to content

Latest commit

Β 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CipherNebula: High-Performance Zero-Knowledge Proof Framework

C/C++ GitHub Stars GitHub Forks Watchers PRs Welcome

🌐 Project Vision

Build a post-quantum secure zero-knowledge proof (ZKP) ecosystem integrating cryptographic primitives, optimized algorithms, and engineering tooling. Designed for blockchain, privacy computing, and secure multi-party computation, CipherNebula accelerates ZKP deployment with modular design and industrial-grade performance.

πŸš€ Core Features

1. 🧠 Universal ZKP Development Template

A modular toolkit for constructing ZKP circuits across cryptographic scenarios:

Fundamental Operation Suite

  • Finite Field Engine

    • Arbitrary-precision arithmetic: add, sub, mul, div, scalar_mul
    • Custom field support: Define prime/characteristic via field_params.h
    • Performance: Optimized for 64-bit architectures using SIMD vectorization
  • Bitwise Logic Library

    • Low-level operations: XOR, bitwise shift, rotation, mask operations
    • Circuit-friendly design: Fixed-time implementations to resist timing attacks
  • Group Theory Abstraction

    • Elliptic curve groups (BN254, Secp256k1) and multiplicative groups
    • Bilinear pairing support for zk-SNARKs/STARKs-style proofs

2. πŸ”„ Ring Domain Modulo Fix (C Language)

Solve the long-standing sign ambiguity in C's % operator for ring domains:

  • Mathematical Accuracy: Enforce a mod n ∈ [0, n) for negative integers
  • API Design: safe_mod(a, n) and ring_sub(a, b, n) for type-safe computations
  • Use Case: Critical for polynomial commitment schemes and lattice-based cryptography

3. βš›οΈ Post-Quantum LWE Module

A hardened implementation of Learning-with-Errors (LWE) problem:

  • Algorithm: BKZ 2.0 with blockwise SWEEP for lattice basis reduction
  • Security Levels: Supports 128-bit/256-bit security via lwe_params.h
  • Interoperability: Compatible with Kyber/Saber post-quantum encryption standards

4. πŸ›‘οΈ ElGamal Encryption Toolchain

Industrial-grade implementation with homomorphic extensions:

  • Functionalities:
    • Key generation (elgamal_keygen), encryption (elgamal_encrypt), decryption (elgamal_decrypt)
    • Additive homomorphism: encrypt(a) + encrypt(b) = encrypt(a+b)
  • Performance Suite:
    • Throughput benchmarking: Compare with RSA/ECC using tests/benchmark.py
    • Memory profiling: Valgrind-compatible for low-latency optimization

πŸ› οΈ Technical Edge

Advantage Details
Full-Stack Coverage From assembly-optimized primitives to high-level proof systems (e.g., Groth16)
Formal Verification Core arithmetic modules verified via Coq/ACL2 for zero computational errors
Post-Quantum Ready Lattice-based foundations future-proof against quantum attacks
Multi-Language Support C/C++ core with Rust FFI bindings (see rust-bindings/ directory)

🌱 Quick Start

1. Environment Setup

# Dependencies (Ubuntu/Debian)  
sudo apt update && sudo apt install -y \  
  build-essential cmake \  
  libgmp3-dev libntl-dev \  
  valgrind python3-benchmark  

# macOS (Homebrew)  
brew install gmp ntl cmake  

2. Code Structure

β”œβ”€β”€ src/                        
β”‚   β”œβ”€β”€ crypto/                # Cryptographic primitives (field, group, lattice)  
β”‚   β”œβ”€β”€ algorithms/            # ZKP algorithms (Groth16, ElGamal, LWE)  
β”‚   β”œβ”€β”€ utils/                 # Core utilities (modulo fix, memory management)  
β”‚   └── bindings/              # Rust/Python interface stubs  
β”œβ”€β”€ examples/                  # Ready-to-run ZKP demos (e.g., hash proof, circuit satisfiability)  
β”œβ”€β”€ tests/                     # Unit tests & fuzzing (via Google Test)  
└── docs/                      # API references & mathematical specifications  

3. Compilation

mkdir build && cd build  
cmake .. -DCMAKE_BUILD_TYPE=RELEASE  # Debug: -DCMAKE_BUILD_TYPE=DEBUG  
make -j$(nproc)  

4. First Proof Example

// Generate a simple proof for "3 * 4 = 12"  
#include "zkp_prover.h"

int main() {  
  ZKPSystem system = zkp_init("arithmetic_circuit");  
  zkp_add_witness(system, 3, 4);  
  zkp_generate_proof(system);  
  bool valid = zkp_verify_proof(system);  
  printf("Proof validity: %s\n", valid ? "VALID" : "INVALID");  
  return 0;  
}  

πŸ“– Documentation

🀝 Community & Support

  • Issues: Report bugs/feature requests in GitHub Issues
  • PRs: Welcome! Follow CONTRIBUTING.md for code style & testing requirements
  • Discussions: Join our Telegram Group for technical talks

βš–οΈ License

Released under the MIT License, allowing commercial use, modification, and distribution. See LICENSE for details.

Module-Specific Compilation Guides

1. Proof Generation & Verification (Example Workflow)
# Navigate to your project directory  
cd [your_project_path]  

# Build proof generator with debug symbols  
gcc -std=c99 [proof_source].c -fopenmp -lssl -lcrypt -lcrypto [required_libs] -o [proof_executable] -g  
# Build verifier  
gcc -std=c99 [verifier_source].c -fopenmp -lssl -lcrypt -lcrypto [required_libs] -o [verifier_executable] -g  

# Execution example  
Generate proof: ./[proof_executable]  
Verify proof: ./[verifier_executable] [output_file]  # Replace with your actual output file  
2. Algorithm Compilation (e.g., Cryptographic Primitives)
cd [algorithm_directory]  # Replace with your module path  
gcc -std=c99 [core_source].c -fopenmp -lssl -lcrypt -lcrypto [dependent_libs] -o [algorithm_executable] -g  
3. Lattice-Based Cryptography Programs
cd [lattice_tool_directory]  
gcc -std=c99 [lattice_source].c -fopenmp -lssl -lcrypt -lcrypto -lgmp -o [lattice_executable] -g  
4. Encryption Algorithm (e.g., ElGamal)
# Enter the algorithm directory  
cd [encryption_module_path]  
# Build optimized release version  
gcc -std=c99 -O3 -fopenmp -o [encryption_executable] [source_file].c -lssl -lcrypto -lrt  

# Execution workflow  
Encrypt: ./[encryption_executable] encrypt [plaintext_file]  
Decrypt: ./[encryption_executable] decrypt [ciphertext_file]  
5. Framework Compilation (e.g., zkboo)
cd [framework_directory]  # Replace with your framework path  
gcc -std=c99 [framework_source].c -fopenmp -lssl -lcrypt -lcrypto -o [framework_executable] -g  

Debugging & Optimization Tips

# GDB debugging (requires core file generation: ulimit -c unlimited)  
gdb [executable] core  # Debug with core dump  

# Release build (remove debug symbols, improve performance)  
gcc -std=c99 [source_file].c -fopenmp -lssl -lcrypt -lcrypto [required_libs] -O3 -o [executable]  

Path & Dependency Notes

  1. Path Convention:

    • Replace all [your_project_path]/[module_directory] with your actual file paths.
    • Use absolute paths for Windows systems (e.g., C:\Project\Module).
  2. Dependency Installation:

    • Install required libraries via package managers (e.g., libgmp, libssl).
    • Adjust library flags (-lgmp, -lm) based on your project’s dependencies.
  3. Customization:

    • Modify compilation flags (e.g., -fopenmp, -O3) based on your hardware and use case (debug/release).

This guide enables compiling executables for different modules, supporting debugging, performance optimization, and encryption feature extensions. Use -O3 for release builds and configure the debug environment with ulimit -c unlimited for debugging.

Contribution & Feedback

Welcome to submit bug reports or feature suggestions via GitHub Issues. High-quality PRs will be prioritized for merging.

CipherNebula: Building the Future of Privacy-Preserving Computation
GitHub β€’ Website β€’ Twitter

Building a Secure and Trustworthy Next-Generation Cryptographic Infrastructure to Accelerate Privacy Computing Adoption

About

This repository is used to record some simulation - implemented solutions, mainly covering areas such as post - quantum cryptography, zero - knowledge proofs, and privacy - preserving protocols.

Resources

Stars

135 stars

Watchers

7 watching

Forks

Releases

Packages

Used by

Contributors

Languages