GSW-RS
A Rust implementation of the GSW (Gentry–Sahai–Waters) lattice-based fully homomorphic encryption scheme.
Features
- LWE-based key generation — Learning With Errors for security
- Bit encryption/decryption — Encrypt bits 0 and 1
- Homomorphic operations — XOR (addition mod 2), AND (multiplication), NAND
- Bootstrapping — Homomorphic evaluation of the decryption circuit to refresh noisy ciphertexts
Building
Running
The demo shows key generation, encryption/decryption, homomorphic XOR/AND/NAND, and bootstrapping.
Usage
use ;
use ;
use thread_rng;
let params = toy;
let mut rng = thread_rng;
let = gsw_keygen;
// Encrypt bits
let ct0 = encrypt;
let ct1 = encrypt;
// Homomorphic XOR (addition mod 2)
let ct_xor = homomorphic_add;
assert_eq!;
// Homomorphic AND (multiplication)
let ct_and = homomorphic_mult;
assert_eq!;
// Bootstrapping (requires evaluation key)
use ;
let ek = gen_evaluation_key;
let ct_noisy = homomorphic_mult;
let ct_refreshed = bootstrap;
assert_eq!;
Testing
Tests cover encrypt/decrypt, homomorphic operations (both seeded and non-deterministic RNG), and bootstrapping.
Parameters
- Toy —
q=2^20,n=8— Fast, for development and testing - Low — Higher security (~64-bit)
- Medium — Higher security (~128-bit)
References
- Gentry, Sahai, Waters: "Homomorphic Encryption from Learning With Errors"
- The GSW FHE Scheme