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
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ autobenches = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
qfall-math = { git = "https://github.com/qfall/math", rev="5f50c9cd31c869462d959774fb4b51fcd1727dbe" }
qfall-math = { git = "https://github.com/qfall/math", branch = "dev" }
flint-sys = "0.7.3"
sha2 = "0.10.6"
serde = {version="1.0", features=["derive"]}
serde_json = "1.0"
typetag = "0.2"
criterion = { version = "0.7", features = ["html_reports"] }
criterion = { version = "0.8", features = ["html_reports"] }

[profile.bench]
debug = true
Expand Down
11 changes: 2 additions & 9 deletions src/primitive/psf/gpv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl PSF for PSFGPV {
/// ```
fn samp_d(&self) -> MatZ {
let m = &self.gp.n * &self.gp.k + &self.gp.m_bar;
MatZ::sample_d_common(&m, &self.gp.n, &self.s).unwrap()
MatZ::sample_discrete_gauss(&m, 1, 0, &self.s).unwrap()
}

/// Samples an `e` in the domain using SampleD with a short basis that is generated
Expand Down Expand Up @@ -157,14 +157,7 @@ impl PSF for PSFGPV {

let center = MatQ::from(&(-1 * &sol));

sol + MatZ::sample_d_precomputed_gso(
short_base,
short_base_gso,
&self.gp.n,
&center,
&self.s,
)
.unwrap()
sol + MatZ::sample_d_precomputed_gso(short_base, short_base_gso, &center, &self.s).unwrap()
}

/// Implements the efficiently computable function `f_a` which here corresponds to
Expand Down
3 changes: 1 addition & 2 deletions src/primitive/psf/gpv_ring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl PSF for PSFGPVRing {
/// ```
fn samp_d(&self) -> MatPolyOverZ {
let dimension = self.gp.modulus.get_degree() * (&self.gp.k + 2);
let sample = MatZ::sample_d_common(dimension, &self.gp.n, &self.s).unwrap();
let sample = MatZ::sample_discrete_gauss(dimension, 1, 0, &self.s).unwrap();
MatPolyOverZ::from_coefficient_embedding((&sample, self.gp.modulus.get_degree() - 1))
}

Expand Down Expand Up @@ -205,7 +205,6 @@ impl PSF for PSFGPVRing {
+ MatPolyOverZ::sample_d(
&short_basis,
self.gp.modulus.get_degree(),
&self.gp.n,
&center_embedded,
&self.s,
)
Expand Down
15 changes: 4 additions & 11 deletions src/primitive/psf/mp_perturbation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,8 @@ pub(crate) fn randomized_nearest_plane_gadget(

// just as PSFGPV::samp_p
long_solution
+ MatZ::sample_d_precomputed_gso(
short_basis_gadget,
short_basis_gadget_gso,
&psf.gp.n,
&center,
&s,
)
.unwrap()
+ MatZ::sample_d_precomputed_gso(short_basis_gadget, short_basis_gadget_gso, &center, &s)
.unwrap()
}

impl PSF for PSFPerturbation {
Expand Down Expand Up @@ -269,7 +263,7 @@ impl PSF for PSFPerturbation {
/// ```
fn samp_d(&self) -> MatZ {
let m = &self.gp.n * &self.gp.k + &self.gp.m_bar;
MatZ::sample_d_common(&m, &self.gp.n, &self.s * &self.r).unwrap()
MatZ::sample_discrete_gauss(m, 1, 0, &self.s * &self.r).unwrap()
}

/// Samples an `e` in the domain using SampleD that is generated
Expand Down Expand Up @@ -318,8 +312,7 @@ impl PSF for PSFPerturbation {
vec_u: &MatZq,
) -> MatZ {
// Sample perturbation p <- D_{ZZ^m, r * √Σ_2}
let vec_p =
MatZ::sample_d_common_non_spherical(&self.gp.n, mat_sqrt_sigma_2, &self.r).unwrap();
let vec_p = MatZ::sample_d_common_non_spherical(mat_sqrt_sigma_2, &self.r).unwrap();

// v = u - A * p
let vec_v = vec_u - mat_a * &vec_p;
Expand Down
2 changes: 1 addition & 1 deletion src/sample/g_trapdoor/trapdoor_distribution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl TrapdoorDistributionRing for SampleZ {
let nr_cols = i64::try_from(nr_cols).unwrap();
let mut out_mat = MatPolyOverZ::new(1, nr_cols);
for j in 0..nr_cols {
let sample = PolyOverZ::sample_discrete_gauss(n - 1, n, 0, s).unwrap();
let sample = PolyOverZ::sample_discrete_gauss(n - 1, 0, s).unwrap();
out_mat.set_entry(0, j, &sample).unwrap();
}

Expand Down
1 change: 1 addition & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@

pub mod common_encodings;
pub mod common_moduli;
pub mod lossy_compression;
pub mod rotation_matrix;
Loading
Loading