diff --git a/core/src/ggsw/ciphertext.rs b/core/src/ggsw/ciphertext.rs index e52f305..13049f5 100644 --- a/core/src/ggsw/ciphertext.rs +++ b/core/src/ggsw/ciphertext.rs @@ -20,6 +20,8 @@ pub struct GGSWCiphertext { impl GGSWCiphertext, FFT64> { pub fn alloc(module: &Module, basek: usize, k: usize, rows: usize, digits: usize, rank: usize) -> Self { let size: usize = k.div_ceil(basek); + debug_assert!(digits > 0, "invalid ggsw: `digits` == 0"); + debug_assert!( size > digits, "invalid ggsw: ceil(k/basek): {} <= digits: {}", diff --git a/core/src/glwe/ciphertext.rs b/core/src/glwe/ciphertext.rs index d0fb39c..07b4264 100644 --- a/core/src/glwe/ciphertext.rs +++ b/core/src/glwe/ciphertext.rs @@ -79,7 +79,7 @@ impl + AsRef<[u8]>> SetMetaData for GLWECiphertext GLWECiphertext<&[u8]>; } @@ -93,7 +93,7 @@ impl> GLWECiphertextToRef for GLWECiphertext { } } -pub trait GLWECiphertextToMut { +pub trait GLWECiphertextToMut: Infos { fn to_mut(&mut self) -> GLWECiphertext<&mut [u8]>; } diff --git a/core/src/glwe/ops.rs b/core/src/glwe/ops.rs index d921583..9248e85 100644 --- a/core/src/glwe/ops.rs +++ b/core/src/glwe/ops.rs @@ -2,11 +2,11 @@ use backend::{FFT64, Module, Scratch, VecZnx, VecZnxOps, ZnxZero}; use crate::{GLWECiphertext, GLWECiphertextToMut, GLWECiphertextToRef, Infos, SetMetaData}; -pub trait GLWEOps: GLWECiphertextToMut + Infos + SetMetaData { +pub trait GLWEOps: GLWECiphertextToMut + SetMetaData { fn add(&mut self, module: &Module, a: &A, b: &B) where - A: GLWECiphertextToRef + Infos, - B: GLWECiphertextToRef + Infos, + A: GLWECiphertextToRef, + B: GLWECiphertextToRef, { #[cfg(debug_assertions)] { @@ -75,8 +75,8 @@ pub trait GLWEOps: GLWECiphertextToMut + Infos + SetMetaData { fn sub(&mut self, module: &Module, a: &A, b: &B) where - A: GLWECiphertextToRef + Infos, - B: GLWECiphertextToRef + Infos, + A: GLWECiphertextToRef, + B: GLWECiphertextToRef, { #[cfg(debug_assertions)] { @@ -230,7 +230,7 @@ pub trait GLWEOps: GLWECiphertextToMut + Infos + SetMetaData { fn normalize(&mut self, module: &Module, a: &A, scratch: &mut Scratch) where - A: GLWECiphertextToRef + Infos, + A: GLWECiphertextToRef, { #[cfg(debug_assertions)] {