Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
185 changes: 82 additions & 103 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions crates/bfv-helpers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ rand.workspace = true
anyhow.workspace = true
fhe-util = { git = "https://github.com/gnosisguild/fhe.rs" }
greco = { package = "zkfhe-greco", git = "https://github.com/gnosisguild/zkfhe-generator", version = "0.1.0"}
num-bigint = { workspace = true }

[dev-dependencies]
hex.workspace = true
36 changes: 26 additions & 10 deletions crates/bfv-helpers/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn bfv_encrypt<T>(
where
Plaintext: for<'a> FheEncoder<&'a T, Error = FheError>,
{
let params = build_bfv_params_arc(degree, plaintext_modulus, &moduli);
let params = build_bfv_params_arc(degree, plaintext_modulus, &moduli, None);

let pk = PublicKey::from_bytes(&public_key, &params)
.map_err(|e| anyhow!("Error deserializing public key:{e}"))?;
Expand Down Expand Up @@ -91,7 +91,7 @@ pub fn bfv_verifiable_encrypt<T>(
where
Plaintext: for<'a> FheEncoder<&'a T, Error = FheError>,
{
let params = build_bfv_params_arc(degree, plaintext_modulus, &moduli);
let params = build_bfv_params_arc(degree, plaintext_modulus, &moduli, None);

let pk = PublicKey::from_bytes(&public_key, &params)
.map_err(|e| anyhow!("Error deserializing public key: {}", e))?;
Expand Down Expand Up @@ -131,11 +131,15 @@ mod tests {

#[test]
fn test_bfv_encrypt_a64() {
use crate::build_bfv_params_from_set_arc;
use fhe::bfv::{Ciphertext, PublicKey, SecretKey};
use fhe_traits::{DeserializeParametrized, FheDecrypter, Serialize};

let (degree, plaintext_modulus, moduli) = SET_2048_1032193_1;
let params = build_bfv_params_arc(degree, plaintext_modulus, &moduli);
let param_set = SET_2048_1032193_1;
let params = build_bfv_params_from_set_arc(param_set);
let degree = param_set.degree;
let plaintext_modulus = param_set.plaintext_modulus;
let moduli = [param_set.moduli[0]];
let mut rng = thread_rng();
let sk = SecretKey::random(&params, &mut rng);
let pk = PublicKey::new(&sk, &mut rng);
Expand All @@ -152,11 +156,15 @@ mod tests {

#[test]
fn test_bfv_encrypt_v64() {
use crate::build_bfv_params_from_set_arc;
use fhe::bfv::{Ciphertext, PublicKey, SecretKey};
use fhe_traits::{DeserializeParametrized, FheDecrypter, Serialize};

let (degree, plaintext_modulus, moduli) = SET_2048_1032193_1;
let params = build_bfv_params_arc(degree, plaintext_modulus, &moduli);
let param_set = SET_2048_1032193_1;
let params = build_bfv_params_from_set_arc(param_set);
let degree = param_set.degree;
let plaintext_modulus = param_set.plaintext_modulus;
let moduli = [param_set.moduli[0]];
let mut rng = thread_rng();
let sk = SecretKey::random(&params, &mut rng);
let pk = PublicKey::new(&sk, &mut rng);
Expand All @@ -180,11 +188,15 @@ mod tests {

#[test]
fn test_bfv_verifiable_encrypt_a64() {
use crate::build_bfv_params_from_set_arc;
use fhe::bfv::{Ciphertext, PublicKey, SecretKey};
use fhe_traits::{DeserializeParametrized, FheDecrypter, Serialize};

let (degree, plaintext_modulus, moduli) = SET_2048_1032193_1;
let params = build_bfv_params_arc(degree, plaintext_modulus, &moduli);
let param_set = SET_2048_1032193_1;
let params = build_bfv_params_from_set_arc(param_set);
let degree = param_set.degree;
let plaintext_modulus = param_set.plaintext_modulus;
let moduli = [param_set.moduli[0]];
let mut rng = thread_rng();
let sk = SecretKey::random(&params, &mut rng);
let pk = PublicKey::new(&sk, &mut rng);
Expand All @@ -201,11 +213,15 @@ mod tests {

#[test]
fn test_bfv_verifiable_encrypt_v64() {
use crate::build_bfv_params_from_set_arc;
use fhe::bfv::{Ciphertext, PublicKey, SecretKey};
use fhe_traits::{DeserializeParametrized, FheDecrypter, Serialize};

let (degree, plaintext_modulus, moduli) = SET_2048_1032193_1;
let params = build_bfv_params_arc(degree, plaintext_modulus, &moduli);
let param_set = SET_2048_1032193_1;
let params = build_bfv_params_from_set_arc(param_set);
let degree = param_set.degree;
let plaintext_modulus = param_set.plaintext_modulus;
let moduli = [param_set.moduli[0]];
let mut rng = thread_rng();
let sk = SecretKey::random(&params, &mut rng);
let pk = PublicKey::new(&sk, &mut rng);
Expand Down
Loading
Loading