mirror of
https://github.com/arnaucube/poulpy.git
synced 2026-02-10 13:16:44 +01:00
Added bytes_of to structs that can be created through the trait extension of Scratch
This commit is contained in:
@@ -26,6 +26,10 @@ impl AutomorphismKey<Vec<u8>, FFT64> {
|
|||||||
p: 0,
|
p: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn bytes_of(module: &Module<FFT64>, basek: usize, k: usize, rows: usize, rank: usize) -> usize {
|
||||||
|
GLWESwitchingKey::<Vec<u8>, FFT64>::bytes_of(module, basek, k, rows, rank, rank)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, B: Backend> Infos for AutomorphismKey<T, B> {
|
impl<T, B: Backend> Infos for AutomorphismKey<T, B> {
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ impl<B: Backend> GGLWECiphertext<Vec<u8>, B> {
|
|||||||
k,
|
k,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn bytes_of(module: &Module<FFT64>, basek: usize, k: usize, rows: usize, rank_in: usize, rank_out: usize) -> usize {
|
||||||
|
module.bytes_of_mat_znx_dft(rows, rank_in, rank_out + 1, derive_size(basek, k))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, B: Backend> Infos for GGLWECiphertext<T, B> {
|
impl<T, B: Backend> Infos for GGLWECiphertext<T, B> {
|
||||||
|
|||||||
@@ -31,6 +31,10 @@ impl<B: Backend> GGSWCiphertext<Vec<u8>, B> {
|
|||||||
k: k,
|
k: k,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn bytes_of(module: &Module<FFT64>, basek: usize, k: usize, rows: usize, rank: usize) -> usize {
|
||||||
|
module.bytes_of_mat_znx_dft(rows, rank + 1, rank + 1, derive_size(basek, k))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, B: Backend> Infos for GGSWCiphertext<T, B> {
|
impl<T, B: Backend> Infos for GGSWCiphertext<T, B> {
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ impl GLWECiphertext<Vec<u8>> {
|
|||||||
k,
|
k,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn bytes_of(module: &Module<FFT64>, basek: usize, k: usize, rank: usize) -> usize {
|
||||||
|
module.bytes_of_vec_znx(rank + 1, derive_size(basek, k))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Infos for GLWECiphertext<T> {
|
impl<T> Infos for GLWECiphertext<T> {
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ impl<B: Backend> GLWECiphertextFourier<Vec<u8>, B> {
|
|||||||
k: k,
|
k: k,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn bytes_of(module: &Module<B>, basek: usize, k: usize, rank: usize) -> usize {
|
||||||
|
module.bytes_of_vec_znx_dft(rank + 1, derive_size(basek, k))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, B: Backend> Infos for GLWECiphertextFourier<T, B> {
|
impl<T, B: Backend> Infos for GLWECiphertextFourier<T, B> {
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ impl SecretKey<Vec<u8>> {
|
|||||||
dist: SecretDistribution::NONE,
|
dist: SecretDistribution::NONE,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn bytes_of(module: &Module<FFT64>, rank: usize) -> usize {
|
||||||
|
module.bytes_of_scalar_znx(rank + 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<DataSelf> SecretKey<DataSelf> {
|
impl<DataSelf> SecretKey<DataSelf> {
|
||||||
@@ -89,6 +93,10 @@ impl<B: Backend> SecretKeyFourier<Vec<u8>, B> {
|
|||||||
dist: SecretDistribution::NONE,
|
dist: SecretDistribution::NONE,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn bytes_of(module: &Module<B>, rank: usize) -> usize {
|
||||||
|
module.bytes_of_scalar_znx_dft(rank + 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: AsRef<[u8]> + AsMut<[u8]>> SecretKeyFourier<D, FFT64> {
|
impl<D: AsRef<[u8]> + AsMut<[u8]>> SecretKeyFourier<D, FFT64> {
|
||||||
@@ -124,6 +132,10 @@ impl<B: Backend> GLWEPublicKey<Vec<u8>, B> {
|
|||||||
dist: SecretDistribution::NONE,
|
dist: SecretDistribution::NONE,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn bytes_of(module: &Module<B>, basek: usize, k: usize, rank: usize) -> usize {
|
||||||
|
GLWECiphertextFourier::<Vec<u8>, B>::bytes_of(module, basek, k, rank)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, B: Backend> Infos for GLWEPublicKey<T, B> {
|
impl<T, B: Backend> Infos for GLWEPublicKey<T, B> {
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ impl GLWESwitchingKey<Vec<u8>, FFT64> {
|
|||||||
module, basek, k, rows, rank_in, rank_out,
|
module, basek, k, rows, rank_in, rank_out,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn bytes_of(module: &Module<FFT64>, basek: usize, k: usize, rows: usize, rank_in: usize, rank_out: usize) -> usize {
|
||||||
|
GGLWECiphertext::<Vec<u8>, FFT64>::bytes_of(module, basek, k, rows, rank_in, rank_out)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, B: Backend> Infos for GLWESwitchingKey<T, B> {
|
impl<T, B: Backend> Infos for GLWESwitchingKey<T, B> {
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ impl TensorKey<Vec<u8>, FFT64> {
|
|||||||
});
|
});
|
||||||
Self { keys: keys }
|
Self { keys: keys }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn bytes_of(module: &Module<FFT64>, basek: usize, k: usize, rows: usize, rank: usize) -> usize {
|
||||||
|
let pairs: usize = (((rank + 1) * rank) >> 1).max(1);
|
||||||
|
pairs * GLWESwitchingKey::<Vec<u8>, FFT64>::bytes_of(module, basek, k, rows, 1, rank)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, B: Backend> Infos for TensorKey<T, B> {
|
impl<T, B: Backend> Infos for TensorKey<T, B> {
|
||||||
|
|||||||
Reference in New Issue
Block a user