arnaucube
arnaucube/poulpyPublic Self-hosted repository
poulpy/backend/src/hal/oep/vec_znx_big.rs
backend/src/hal/oep/vec_znx_big.rsRaw
  1use rand_distr::Distribution;
  2use sampling::source::Source;
  3
  4use crate::hal::layouts::{Backend, Module, Scratch, VecZnxBigOwned, VecZnxBigToMut, VecZnxBigToRef, VecZnxToMut, VecZnxToRef};
  5
  6pub unsafe trait VecZnxBigAllocImpl<B: Backend> {
  7    fn vec_znx_big_alloc_impl(n: usize, cols: usize, size: usize) -> VecZnxBigOwned<B>;
  8}
  9
 10pub unsafe trait VecZnxBigFromBytesImpl<B: Backend> {
 11    fn vec_znx_big_from_bytes_impl(n: usize, cols: usize, size: usize, bytes: Vec<u8>) -> VecZnxBigOwned<B>;
 12}
 13
 14pub unsafe trait VecZnxBigAllocBytesImpl<B: Backend> {
 15    fn vec_znx_big_alloc_bytes_impl(n: usize, cols: usize, size: usize) -> usize;
 16}
 17
 18pub unsafe trait VecZnxBigAddNormalImpl<B: Backend> {
 19    fn add_normal_impl<R: VecZnxBigToMut<B>>(
 20        module: &Module<B>,
 21        basek: usize,
 22        res: &mut R,
 23        res_col: usize,
 24        k: usize,
 25        source: &mut Source,
 26        sigma: f64,
 27        bound: f64,
 28    );
 29}
 30
 31pub unsafe trait VecZnxBigFillNormalImpl<B: Backend> {
 32    fn fill_normal_impl<R: VecZnxBigToMut<B>>(
 33        module: &Module<B>,
 34        basek: usize,
 35        res: &mut R,
 36        res_col: usize,
 37        k: usize,
 38        source: &mut Source,
 39        sigma: f64,
 40        bound: f64,
 41    );
 42}
 43
 44pub unsafe trait VecZnxBigFillDistF64Impl<B: Backend> {
 45    fn fill_dist_f64_impl<R: VecZnxBigToMut<B>, D: Distribution<f64>>(
 46        module: &Module<B>,
 47        basek: usize,
 48        res: &mut R,
 49        res_col: usize,
 50        k: usize,
 51        source: &mut Source,
 52        dist: D,
 53        bound: f64,
 54    );
 55}
 56
 57pub unsafe trait VecZnxBigAddDistF64Impl<B: Backend> {
 58    fn add_dist_f64_impl<R: VecZnxBigToMut<B>, D: Distribution<f64>>(
 59        module: &Module<B>,
 60        basek: usize,
 61        res: &mut R,
 62        res_col: usize,
 63        k: usize,
 64        source: &mut Source,
 65        dist: D,
 66        bound: f64,
 67    );
 68}
 69
 70pub unsafe trait VecZnxBigAddImpl<B: Backend> {
 71    fn vec_znx_big_add_impl<R, A, C>(module: &Module<B>, res: &mut R, res_col: usize, a: &A, a_col: usize, b: &C, b_col: usize)
 72    where
 73        R: VecZnxBigToMut<B>,
 74        A: VecZnxBigToRef<B>,
 75        C: VecZnxBigToRef<B>;
 76}
 77
 78pub unsafe trait VecZnxBigAddInplaceImpl<B: Backend> {
 79    fn vec_znx_big_add_inplace_impl<R, A>(module: &Module<B>, res: &mut R, res_col: usize, a: &A, a_col: usize)
 80    where
 81        R: VecZnxBigToMut<B>,
 82        A: VecZnxBigToRef<B>;
 83}
 84
 85pub unsafe trait VecZnxBigAddSmallImpl<B: Backend> {
 86    fn vec_znx_big_add_small_impl<R, A, C>(
 87        module: &Module<B>,
 88        res: &mut R,
 89        res_col: usize,
 90        a: &A,
 91        a_col: usize,
 92        b: &C,
 93        b_col: usize,
 94    ) where
 95        R: VecZnxBigToMut<B>,
 96        A: VecZnxBigToRef<B>,
 97        C: VecZnxToRef;
 98}
 99
100pub unsafe trait VecZnxBigAddSmallInplaceImpl<B: Backend> {
101    fn vec_znx_big_add_small_inplace_impl<R, A>(module: &Module<B>, res: &mut R, res_col: usize, a: &A, a_col: usize)
102    where
103        R: VecZnxBigToMut<B>,
104        A: VecZnxToRef;
105}
106
107pub unsafe trait VecZnxBigSubImpl<B: Backend> {
108    fn vec_znx_big_sub_impl<R, A, C>(module: &Module<B>, res: &mut R, res_col: usize, a: &A, a_col: usize, b: &C, b_col: usize)
109    where
110        R: VecZnxBigToMut<B>,
111        A: VecZnxBigToRef<B>,
112        C: VecZnxBigToRef<B>;
113}
114
115pub unsafe trait VecZnxBigSubABInplaceImpl<B: Backend> {
116    fn vec_znx_big_sub_ab_inplace_impl<R, A>(module: &Module<B>, res: &mut R, res_col: usize, a: &A, a_col: usize)
117    where
118        R: VecZnxBigToMut<B>,
119        A: VecZnxBigToRef<B>;
120}
121
122pub unsafe trait VecZnxBigSubBAInplaceImpl<B: Backend> {
123    fn vec_znx_big_sub_ba_inplace_impl<R, A>(module: &Module<B>, res: &mut R, res_col: usize, a: &A, a_col: usize)
124    where
125        R: VecZnxBigToMut<B>,
126        A: VecZnxBigToRef<B>;
127}
128
129pub unsafe trait VecZnxBigSubSmallAImpl<B: Backend> {
130    fn vec_znx_big_sub_small_a_impl<R, A, C>(
131        module: &Module<B>,
132        res: &mut R,
133        res_col: usize,
134        a: &A,
135        a_col: usize,
136        b: &C,
137        b_col: usize,
138    ) where
139        R: VecZnxBigToMut<B>,
140        A: VecZnxToRef,
141        C: VecZnxBigToRef<B>;
142}
143
144pub unsafe trait VecZnxBigSubSmallAInplaceImpl<B: Backend> {
145    fn vec_znx_big_sub_small_a_inplace_impl<R, A>(module: &Module<B>, res: &mut R, res_col: usize, a: &A, a_col: usize)
146    where
147        R: VecZnxBigToMut<B>,
148        A: VecZnxToRef;
149}
150
151pub unsafe trait VecZnxBigSubSmallBImpl<B: Backend> {
152    fn vec_znx_big_sub_small_b_impl<R, A, C>(
153        module: &Module<B>,
154        res: &mut R,
155        res_col: usize,
156        a: &A,
157        a_col: usize,
158        b: &C,
159        b_col: usize,
160    ) where
161        R: VecZnxBigToMut<B>,
162        A: VecZnxBigToRef<B>,
163        C: VecZnxToRef;
164}
165
166pub unsafe trait VecZnxBigSubSmallBInplaceImpl<B: Backend> {
167    fn vec_znx_big_sub_small_b_inplace_impl<R, A>(module: &Module<B>, res: &mut R, res_col: usize, a: &A, a_col: usize)
168    where
169        R: VecZnxBigToMut<B>,
170        A: VecZnxToRef;
171}
172
173pub unsafe trait VecZnxBigNegateInplaceImpl<B: Backend> {
174    fn vec_znx_big_negate_inplace_impl<A>(module: &Module<B>, a: &mut A, a_col: usize)
175    where
176        A: VecZnxBigToMut<B>;
177}
178
179pub unsafe trait VecZnxBigNormalizeTmpBytesImpl<B: Backend> {
180    fn vec_znx_big_normalize_tmp_bytes_impl(module: &Module<B>, n: usize) -> usize;
181}
182
183pub unsafe trait VecZnxBigNormalizeImpl<B: Backend> {
184    fn vec_znx_big_normalize_impl<R, A>(
185        module: &Module<B>,
186        basek: usize,
187        res: &mut R,
188        res_col: usize,
189        a: &A,
190        a_col: usize,
191        scratch: &mut Scratch<B>,
192    ) where
193        R: VecZnxToMut,
194        A: VecZnxBigToRef<B>;
195}
196
197pub unsafe trait VecZnxBigAutomorphismImpl<B: Backend> {
198    fn vec_znx_big_automorphism_impl<R, A>(module: &Module<B>, k: i64, res: &mut R, res_col: usize, a: &A, a_col: usize)
199    where
200        R: VecZnxBigToMut<B>,
201        A: VecZnxBigToRef<B>;
202}
203
204pub unsafe trait VecZnxBigAutomorphismInplaceImpl<B: Backend> {
205    fn vec_znx_big_automorphism_inplace_impl<A>(module: &Module<B>, k: i64, a: &mut A, a_col: usize)
206    where
207        A: VecZnxBigToMut<B>;
208}