This commit is contained in:
Pro7ech
2025-10-12 21:34:10 +02:00
parent f72363cc4b
commit 662e533eac
32 changed files with 1594 additions and 787 deletions

View File

@@ -1,6 +1,6 @@
use poulpy_hal::{
api::{VmpPMatAlloc, VmpPMatAllocBytes, VmpPrepare, VmpPrepareTmpBytes},
layouts::{Backend, Data, DataMut, DataRef, Module, Scratch, VmpPMat, VmpPMatToRef, ZnxInfos},
layouts::{Backend, Data, DataMut, DataRef, Module, Scratch, VmpPMat, VmpPMatToMut, VmpPMatToRef, ZnxInfos},
oep::VmpPMatAllocBytesImpl,
};
@@ -295,6 +295,22 @@ where
}
}
pub trait GGSWCiphertextPreparedToMut<B: Backend> {
fn to_ref(&mut self) -> GGSWCiphertextPrepared<&mut [u8], B>;
}
impl<D: DataMut, B: Backend> GGSWCiphertextPreparedToMut<B> for GGSWCiphertextPrepared<D, B> {
fn to_ref(&mut self) -> GGSWCiphertextPrepared<&mut [u8], B> {
GGSWCiphertextPrepared::builder()
.base2k(self.base2k())
.dsize(self.dsize())
.k(self.k())
.data(self.data.to_mut())
.build()
.unwrap()
}
}
pub trait GGSWCiphertextPreparedToRef<B: Backend> {
fn to_ref(&self) -> GGSWCiphertextPrepared<&[u8], B>;
}

View File

@@ -1,6 +1,6 @@
use poulpy_hal::{
api::{VecZnxDftAlloc, VecZnxDftAllocBytes, VecZnxDftApply},
layouts::{Backend, Data, DataMut, DataRef, Module, Scratch, VecZnxDft, ZnxInfos},
layouts::{Backend, Data, DataMut, DataRef, Module, Scratch, VecZnxDft, VecZnxDftToMut, VecZnxDftToRef, ZnxInfos},
oep::VecZnxDftAllocBytesImpl,
};
@@ -205,3 +205,33 @@ where
self.dist = other.dist;
}
}
pub trait GLWEPublicKeyPreparedToMut<B: Backend> {
fn to_mut(&mut self) -> GLWEPublicKeyPrepared<&mut [u8], B>;
}
impl<D: DataMut, B: Backend> GLWEPublicKeyPreparedToMut<B> for GLWEPublicKeyPrepared<D, B> {
fn to_mut(&mut self) -> GLWEPublicKeyPrepared<&mut [u8], B> {
GLWEPublicKeyPrepared {
dist: self.dist,
k: self.k,
base2k: self.base2k,
data: self.data.to_mut(),
}
}
}
pub trait GLWEPublicKeyPreparedToRef<B: Backend> {
fn to_ref(&self) -> GLWEPublicKeyPrepared<&[u8], B>;
}
impl<D: DataRef, B: Backend> GLWEPublicKeyPreparedToRef<B> for GLWEPublicKeyPrepared<D, B> {
fn to_ref(&self) -> GLWEPublicKeyPrepared<&[u8], B> {
GLWEPublicKeyPrepared {
data: self.data.to_ref(),
dist: self.dist,
k: self.k,
base2k: self.base2k,
}
}
}

View File

@@ -1,6 +1,6 @@
use poulpy_hal::{
api::{SvpPPolAlloc, SvpPPolAllocBytes, SvpPrepare},
layouts::{Backend, Data, DataMut, DataRef, Module, Scratch, SvpPPol, ZnxInfos},
layouts::{Backend, Data, DataMut, DataRef, Module, Scratch, SvpPPol, SvpPPolToMut, SvpPPolToRef, ZnxInfos},
};
use crate::{
@@ -113,3 +113,29 @@ where
self.dist = other.dist
}
}
pub trait GLWESecretPreparedToRef<B: Backend> {
fn to_ref(&self) -> GLWESecretPrepared<&[u8], B>;
}
impl<D: DataRef, B: Backend> GLWESecretPreparedToRef<B> for GLWESecretPrepared<D, B> {
fn to_ref(&self) -> GLWESecretPrepared<&[u8], B> {
GLWESecretPrepared {
data: self.data.to_ref(),
dist: self.dist,
}
}
}
pub trait GLWESecretPreparedToMut<B: Backend> {
fn to_ref(&mut self) -> GLWESecretPrepared<&mut [u8], B>;
}
impl<D: DataMut, B: Backend> GLWESecretPreparedToMut<B> for GLWESecretPrepared<D, B> {
fn to_ref(&mut self) -> GLWESecretPrepared<&mut [u8], B> {
GLWESecretPrepared {
dist: self.dist,
data: self.data.to_mut(),
}
}
}