use crate::layouts::{ Backend, ScalarZnxToRef, SvpPPolOwned, SvpPPolToMut, SvpPPolToRef, VecZnxDftToMut, VecZnxDftToRef, VecZnxToRef, }; /// Allocates as [crate::layouts::SvpPPol]. pub trait SvpPPolAlloc { fn svp_ppol_alloc(&self, cols: usize) -> SvpPPolOwned; } /// Returns the size in bytes to allocate a [crate::layouts::SvpPPol]. pub trait SvpPPolBytesOf { fn bytes_of_svp_ppol(&self, cols: usize) -> usize; } /// Consume a vector of bytes into a [crate::layouts::MatZnx]. /// User must ensure that bytes is memory aligned and that it length is equal to [SvpPPolAllocBytes]. pub trait SvpPPolFromBytes { fn svp_ppol_from_bytes(&self, cols: usize, bytes: Vec) -> SvpPPolOwned; } /// Prepare a [crate::layouts::ScalarZnx] into an [crate::layouts::SvpPPol]. pub trait SvpPrepare { fn svp_prepare(&self, res: &mut R, res_col: usize, a: &A, a_col: usize) where R: SvpPPolToMut, A: ScalarZnxToRef; } /// Apply a scalar-vector product between `a[a_col]` and `b[b_col]` and stores the result on `res[res_col]`. pub trait SvpApplyDft { fn svp_apply_dft(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, b: &C, b_col: usize) where R: VecZnxDftToMut, A: SvpPPolToRef, C: VecZnxToRef; } /// Apply a scalar-vector product between `a[a_col]` and `b[b_col]` and stores the result on `res[res_col]`. pub trait SvpApplyDftToDft { fn svp_apply_dft_to_dft(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, b: &C, b_col: usize) where R: VecZnxDftToMut, A: SvpPPolToRef, C: VecZnxDftToRef; } /// Apply a scalar-vector product between `a[a_col]` and `b[b_col]` and adds the result on `res[res_col]`. pub trait SvpApplyDftToDftAdd { fn svp_apply_dft_to_dft_add(&self, res: &mut R, res_col: usize, a: &A, a_col: usize, b: &C, b_col: usize) where R: VecZnxDftToMut, A: SvpPPolToRef, C: VecZnxDftToRef; } /// Apply a scalar-vector product between `res[res_col]` and `a[a_col]` and stores the result on `res[res_col]`. pub trait SvpApplyDftToDftInplace { fn svp_apply_dft_to_dft_inplace(&self, res: &mut R, res_col: usize, a: &A, a_col: usize) where R: VecZnxDftToMut, A: SvpPPolToRef; }