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
194 changes: 104 additions & 90 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ members = [
"crates/wasm",
]
exclude = [
"examples/CRISP",
"examples/CRISP/server",
"examples/CRISP/program",
"examples/default/client/wasm",
"examples/default",
# client needs to be able to build crates/support independently
"crates/support",
"crates/support-scripts/dev"
"crates/support-scripts/dev",
"templates/default"
]
resolver = "3"
msrv = "1.86.0"
Expand Down Expand Up @@ -150,12 +150,14 @@ rayon = "=1.10.0"
regex = "=1.11.1"
reqwest = { version = "=0.12.22", features = ["json"] }
serde = { version = "=1.0.228", features = ["derive"] }
serde-wasm-bindgen = "=0.6.5"
serde_json = "=1.0.141"
serial_test = "=3.2.0"
sled = "=0.34.7"
serde_yaml = "=0.9.34"
sha2 = "=0.10.9"
shellexpand = "=3.1.1"
sled = "=0.34.7"
strum = { version = "=0.27.2", features = ["derive"] }
tempfile = "=3.20.0"
thiserror = { version = "=1.0.69" }
tokio = { version = "=1.46.1", features = ["full"] }
Expand Down
14 changes: 7 additions & 7 deletions circuits/crates/libs/greco/src/lib.nr
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ pub struct Greco<let N: u32, let L: u32, let BIT_PK: u32, let BIT_CT: u32, let B
u: Polynomial<N>,
e0: Polynomial<N>,
e1: Polynomial<N>,
e1is: [Polynomial<N>; L],
e0is: [Polynomial<N>; L],
k1: Polynomial<N>,
r1is: [Polynomial<(2 * N) - 1>; L],
r2is: [Polynomial<N - 1>; L],
Expand Down Expand Up @@ -229,14 +229,14 @@ impl<let N: u32, let L: u32, let BIT_PK: u32, let BIT_CT: u32, let BIT_U: u32, l
u: Polynomial<N>,
e0: Polynomial<N>,
e1: Polynomial<N>,
e1is: [Polynomial<N>; L],
e0is: [Polynomial<N>; L],
k1: Polynomial<N>,
r1is: [Polynomial<2 * N - 1>; L],
r2is: [Polynomial<N - 1>; L],
p1is: [Polynomial<2 * N - 1>; L],
p2is: [Polynomial<N - 1>; L],
) -> Greco<N, L, BIT_PK, BIT_CT, BIT_U, BIT_E0, BIT_E1, BIT_K, BIT_R1, BIT_R2, BIT_P1, BIT_P2> {
Greco { params, pk0is, pk1is, ct0is, ct1is, u, e0, e1, e1is, k1, r1is, r2is, p1is, p2is }
Greco { params, pk0is, pk1is, ct0is, ct1is, u, e0, e1, e0is, k1, r1is, r2is, p1is, p2is }
}

/// Flattens all polynomials coefficients into a single array for challenge generation.
Expand Down Expand Up @@ -399,7 +399,7 @@ impl<let N: u32, let L: u32, let BIT_PK: u32, let BIT_CT: u32, let BIT_U: u32, l
// Cyclotomic polynomial evaluation: cyclo(x) = x^N + 1
let cyclo_at_gamma = gamma.pow_32(N as Field) + 1;
let u_at_gamma = self.u.eval(gamma);
let e0_at_gamma = self.e0.eval(gamma);
let e1_at_gamma = self.e1.eval(gamma);
let k1_at_gamma = self.k1.eval(gamma);

let mut sum = (0, 0);
Expand All @@ -409,9 +409,10 @@ impl<let N: u32, let L: u32, let BIT_PK: u32, let BIT_CT: u32, let BIT_U: u32, l
let pk0is_at_gamma = self.pk0is[i].eval(gamma);
let r1i_at_gamma = self.r1is[i].eval(gamma);
let r2i_at_gamma = self.r2is[i].eval(gamma);
let e0is_at_gamma = self.e0is[i].eval(gamma);

// Step 1: pk0_u = pk0i(gamma) * u(gamma) + e0(gamma)
let pk0_u = (pk0is_at_gamma * u_at_gamma) + e0_at_gamma;
let pk0_u = (pk0is_at_gamma * u_at_gamma) + e0is_at_gamma;

// Step 2: rhs = pk0_u + k1(gamma) * k0i
let mut ct0_rhs = pk0_u + (k1_at_gamma * crypto_params.k0is[i]);
Expand All @@ -430,10 +431,9 @@ impl<let N: u32, let L: u32, let BIT_PK: u32, let BIT_CT: u32, let BIT_U: u32, l
let pk1is_at_gamma = self.pk1is[i].eval(gamma);
let p1is_at_gamma = self.p1is[i].eval(gamma);
let p2is_at_gamma = self.p2is[i].eval(gamma);
let e1is_at_gamma = self.e1is[i].eval(gamma);

// Step 1: pk1_u = pk1i(gamma) * u(gamma) + e1(gamma)
let pk1_u = (pk1is_at_gamma * u_at_gamma) + e1is_at_gamma;
let pk1_u = (pk1is_at_gamma * u_at_gamma) + e1_at_gamma;

// Step 2: rhs = pk1_u + p2i(gamma) * cyclo(gamma)
let mut ct1_rhs = pk1_u + p2is_at_gamma * cyclo_at_gamma;
Expand Down
9 changes: 5 additions & 4 deletions crates/bfv-helpers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ repository = "https://github.com/gnosisguild/enclave/crates/bfv-helpers"
[dependencies]
alloy-dyn-abi = { workspace = true }
alloy-primitives = { workspace = true }
fhe-traits.workspace = true
fhe.workspace = true
rand.workspace = true
anyhow.workspace = true
fhe-util = { git = "https://github.com/gnosisguild/fhe.rs" }
fhe-math = { git = "https://github.com/gnosisguild/fhe.rs" }
fhe-traits.workspace = true
fhe-util = { git = "https://github.com/gnosisguild/fhe.rs" }
fhe.workspace = true
greco = { package = "zkfhe-greco", git = "https://github.com/gnosisguild/zkfhe-generator" }
num-bigint = { workspace = true }
strum.workspace = true
rand.workspace = true
thiserror = { workspace = true }

[dev-dependencies]
Expand Down
10 changes: 5 additions & 5 deletions crates/bfv-helpers/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ where

#[cfg(test)]
mod tests {
use crate::params::SET_2048_1032193_1;
use crate::BfvParams;

use super::*;

Expand All @@ -135,7 +135,7 @@ mod tests {
use fhe::bfv::{Ciphertext, PublicKey, SecretKey};
use fhe_traits::{DeserializeParametrized, FheDecrypter, Serialize};

let param_set = SET_2048_1032193_1;
let param_set = BfvParams::InsecureSet2048_1032193_1.into();
let params = build_bfv_params_from_set_arc(param_set);
let degree = param_set.degree;
let plaintext_modulus = param_set.plaintext_modulus;
Expand All @@ -160,7 +160,7 @@ mod tests {
use fhe::bfv::{Ciphertext, PublicKey, SecretKey};
use fhe_traits::{DeserializeParametrized, FheDecrypter, Serialize};

let param_set = SET_2048_1032193_1;
let param_set = BfvParams::InsecureSet2048_1032193_1.into();
let params = build_bfv_params_from_set_arc(param_set);
let degree = param_set.degree;
let plaintext_modulus = param_set.plaintext_modulus;
Expand Down Expand Up @@ -192,7 +192,7 @@ mod tests {
use fhe::bfv::{Ciphertext, PublicKey, SecretKey};
use fhe_traits::{DeserializeParametrized, FheDecrypter, Serialize};

let param_set = SET_2048_1032193_1;
let param_set = BfvParams::InsecureSet2048_1032193_1.into();
let params = build_bfv_params_from_set_arc(param_set);
let degree = param_set.degree;
let plaintext_modulus = param_set.plaintext_modulus;
Expand Down Expand Up @@ -223,7 +223,7 @@ mod tests {
use fhe::bfv::{Ciphertext, PublicKey, SecretKey};
use fhe_traits::{DeserializeParametrized, FheDecrypter, Serialize};

let param_set = SET_2048_1032193_1;
let param_set = BfvParams::InsecureSet2048_1032193_1.into();
let params = build_bfv_params_from_set_arc(param_set);
let degree = param_set.degree;
let plaintext_modulus = param_set.plaintext_modulus;
Expand Down
Loading