Skip to content

Commit

Permalink
Fuzz test
Browse files Browse the repository at this point in the history
  • Loading branch information
Chandan-M-N committed Nov 23, 2024
1 parent e067cd5 commit 8a527b4
Show file tree
Hide file tree
Showing 7 changed files with 752 additions and 15 deletions.
35 changes: 35 additions & 0 deletions examples/test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use ckks_engine::*;
use log::info;

fn test_homomorphic_divide() {
std::env::set_var("RUST_LOG", "info");
env_logger::init();
// Initialize parameters with a higher polynomial degree
let degree = 2048;
let params = CkksParameters::new(degree, 1000000000000007);

// Initialize key generator
let keygen = KeyGenerator::new();
let (public_key, secret_key) = keygen.generate_keys();

// Initialize encryptor and decryptor
let encryptor = CKKSEncryptor::new(public_key.clone(), params.clone());
let decryptor = CKKSDecryptor::new(secret_key.clone(), params.clone());

// Encrypt numerator and denominator
let numerator = [10,20,30];
let denominator = 2;
let encrypted_numerator = encryptor.encrypt_collection(&numerator);
let encrypted_denominator = encryptor.encrypt_value(denominator);

// Perform division with 5 iterations for reciprocal approximation
let encrypted_division = encryptor.homomorphic_divide(&encrypted_numerator, &encrypted_denominator);

// Decrypt the result as integers
let decrypted_division = decryptor.decrypt(&encrypted_division);
info!("Decrypted division result: {:?}", decrypted_division);
}

fn main(){
test_homomorphic_divide()
}
4 changes: 4 additions & 0 deletions fuzz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target
corpus
artifacts
coverage
Loading

0 comments on commit 8a527b4

Please sign in to comment.