mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 13:16:44 +01:00
fixed potential buffer overflow & added vec_znx_normalize_tmp_bytes
This commit is contained in:
@@ -469,6 +469,7 @@ pub fn rsh<T: VecZnxCommon>(log_base2k: usize, a: &mut T, k: usize, carry: &mut
|
|||||||
pub trait VecZnxCommon: VecZnxApi + Infos {}
|
pub trait VecZnxCommon: VecZnxApi + Infos {}
|
||||||
|
|
||||||
pub trait VecZnxOps {
|
pub trait VecZnxOps {
|
||||||
|
|
||||||
/// Allocates a new [VecZnx].
|
/// Allocates a new [VecZnx].
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
@@ -480,6 +481,8 @@ pub trait VecZnxOps {
|
|||||||
/// a new [VecZnx] through [VecZnx::from_bytes].
|
/// a new [VecZnx] through [VecZnx::from_bytes].
|
||||||
fn bytes_of_vec_znx(&self, cols: usize) -> usize;
|
fn bytes_of_vec_znx(&self, cols: usize) -> usize;
|
||||||
|
|
||||||
|
fn vec_znx_normalize_tmp_bytes(&self) -> usize;
|
||||||
|
|
||||||
/// c <- a + b.
|
/// c <- a + b.
|
||||||
fn vec_znx_add<A: VecZnxCommon, B: VecZnxCommon, C: VecZnxCommon>(
|
fn vec_znx_add<A: VecZnxCommon, B: VecZnxCommon, C: VecZnxCommon>(
|
||||||
&self,
|
&self,
|
||||||
@@ -557,6 +560,12 @@ impl VecZnxOps for Module {
|
|||||||
self.n() * cols * 8
|
self.n() * cols * 8
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn vec_znx_normalize_tmp_bytes(&self) -> usize{
|
||||||
|
unsafe{
|
||||||
|
vec_znx::vec_znx_normalize_tmp_bytes(self.0) as usize
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// c <- a + b
|
// c <- a + b
|
||||||
fn vec_znx_add<A: VecZnxCommon, B: VecZnxCommon, C: VecZnxCommon>(
|
fn vec_znx_add<A: VecZnxCommon, B: VecZnxCommon, C: VecZnxCommon>(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
@@ -439,6 +439,7 @@ impl VmpPMatOps for Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn vmp_prepare_row(&self, b: &mut VmpPMat, a: &[i64], row_i: usize, buf: &mut [u8]) {
|
fn vmp_prepare_row(&self, b: &mut VmpPMat, a: &[i64], row_i: usize, buf: &mut [u8]) {
|
||||||
|
debug_assert!(a.len() == b.cols() * self.n());
|
||||||
unsafe {
|
unsafe {
|
||||||
vmp::vmp_prepare_row(
|
vmp::vmp_prepare_row(
|
||||||
self.0,
|
self.0,
|
||||||
|
|||||||
Reference in New Issue
Block a user