Expand description
GSW (Gentry-Sahai-Waters) lattice-based Fully Homomorphic Encryption.
This crate implements the GSW FHE scheme with:
- LWE-based key generation
- Homomorphic addition and multiplication
- Bootstrapping (homomorphic evaluation of decryption)
§Example
ⓘ
use gsw_rs::{gsw_keygen, encrypt, decrypt, homomorphic_add, homomorphic_mult};
use gsw_rs::params::{Params, SecurityLevel};
use rand::thread_rng;
let params = Params::toy();
let mut rng = thread_rng();
let (sk, pk) = gsw_keygen(&mut rng, ¶ms);
let ct0 = encrypt(&mut rng, &pk, 0);
let ct1 = encrypt(&mut rng, &pk, 1);
assert_eq!(decrypt(&sk, &ct0), 0);
assert_eq!(decrypt(&sk, &ct1), 1);
let ct_and = homomorphic_mult(¶ms, &ct1, &ct1);
assert_eq!(decrypt(&sk, &ct_and), 1);Re-exports§
pub use bootstrap::bootstrap;pub use bootstrap::decrypt_linear_part_clear;pub use bootstrap::gen_evaluation_key;pub use bootstrap::EvaluationKey;pub use gadget::bit_decomp;pub use gadget::bit_decomp_inverse;pub use gadget::flatten;pub use gadget::flatten_matrix;pub use gadget::powers_of_2;pub use lwe::keygen;pub use lwe::PublicKey;pub use lwe::SecretKey;pub use params::Params;pub use params::SecurityLevel;
Modules§
- bootstrap
- Bootstrapping for GSW FHE.
- gadget
- Gadget matrix operations: BitDecomp, BitDecompInverse, Flatten, PowersOf2.
- lwe
- LWE (Learning With Errors) primitives.
- modular
- Modular arithmetic utilities for Z_q.
- params
- LWE/GSW parameter definitions.
Functions§
- decrypt
- Decrypt a GSW ciphertext.
- encrypt
- Encrypt a single bit μ ∈ {0, 1}.
- gsw_
keygen - Generate GSW key pair.
- homomorphic_
add - Homomorphic addition: C_+ = C_1 + C_2 (then Flatten).
- homomorphic_
mult - Homomorphic multiplication: C_× = Flatten(C_1 * C_2).
- homomorphic_
nand - Homomorphic NAND: C_nand = Flatten(I - C_1 * C_2).
Type Aliases§
- Ciphertext
- GSW ciphertext: an N×N matrix over Z_q.
- GswPublic
Key - GSW public key.
- GswSecret
Key - GSW secret key (same as LWE secret for this construction).