pub struct PSFGPV {
pub gp: GadgetParameters,
pub s: Q,
}Expand description
A lattice-based implementation of a PSF according to
[1] using
G-Trapdoors where D_n = {e ∈ Z^m | |e| <= s sqrt(m)}
and R_n = Z_q^n.
Attributes
gp: Describes the gadget parameters with which the G-Trapdoor is generateds: The Gaussian parameter with which is sampled
§Examples
use qfall_tools::primitive::psf::PSFGPV;
use qfall_tools::sample::g_trapdoor::gadget_parameters::GadgetParameters;
use qfall_math::rational::Q;
use qfall_tools::primitive::psf::PSF;
let psf = PSFGPV {
gp: GadgetParameters::init_default(8, 64),
s: Q::from(12),
};
let (a, td) = psf.trap_gen();
let domain_sample = psf.samp_d();
let range_fa = psf.f_a(&a, &domain_sample);
let preimage = psf.samp_p(&a, &td, &range_fa);
assert!(psf.check_domain(&preimage));Fields§
§gp: GadgetParameters§s: QTrait Implementations§
Source§impl<'de> Deserialize<'de> for PSFGPV
impl<'de> Deserialize<'de> for PSFGPV
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PSF for PSFGPV
impl PSF for PSFGPV
Source§fn trap_gen(&self) -> (MatZq, (MatZ, MatQ))
fn trap_gen(&self) -> (MatZq, (MatZ, MatQ))
Computes a G-Trapdoor according to the GadgetParameters
defined in the struct.
It returns a matrix A together with a short base and its GSO.
§Examples
use qfall_tools::primitive::psf::PSFGPV;
use qfall_tools::sample::g_trapdoor::gadget_parameters::GadgetParameters;
use qfall_math::rational::Q;
use qfall_tools::primitive::psf::PSF;
let psf = PSFGPV {
gp: GadgetParameters::init_default(8, 64),
s: Q::from(12),
};
let (a, (sh_b, sh_b_gso)) = psf.trap_gen();Source§fn samp_d(&self) -> MatZ
fn samp_d(&self) -> MatZ
Samples in the domain using SampleD with the standard basis and center 0.
§Examples
use qfall_tools::primitive::psf::PSFGPV;
use qfall_tools::sample::g_trapdoor::gadget_parameters::GadgetParameters;
use qfall_math::rational::Q;
use qfall_tools::primitive::psf::PSF;
let psf = PSFGPV {
gp: GadgetParameters::init_default(8, 64),
s: Q::from(12),
};
let (a, td) = psf.trap_gen();
let domain_sample = psf.samp_d();Source§fn samp_p(
&self,
a: &MatZq,
(short_base, short_base_gso): &(MatZ, MatQ),
u: &MatZq,
) -> MatZ
fn samp_p( &self, a: &MatZq, (short_base, short_base_gso): &(MatZ, MatQ), u: &MatZq, ) -> MatZ
Samples an e in the domain using SampleD with a short basis that is generated
from the G-Trapdoor from the conditioned conditioned
discrete Gaussian with f_a(a,e) = u for a provided syndrome u.
Note: the provided parameters a,r,u must fit together,
otherwise unexpected behavior such as panics may occur.
Parameters:
a: The parity-check matrixshort_base: The short base forΛ^⟂(A)short_base_gso: The precomputed GSO of the short_baseu: The syndrome from the range
Returns a sample e from the domain on the conditioned discrete
Gaussian distribution f_a(a,e) = u.
§Examples
use qfall_tools::primitive::psf::PSFGPV;
use qfall_tools::sample::g_trapdoor::gadget_parameters::GadgetParameters;
use qfall_math::rational::Q;
use qfall_tools::primitive::psf::PSF;
let psf = PSFGPV {
gp: GadgetParameters::init_default(8, 64),
s: Q::from(12),
};
let (a, td) = psf.trap_gen();
let domain_sample = psf.samp_d();
let range_fa = psf.f_a(&a, &domain_sample);
let preimage = psf.samp_p(&a, &td, &range_fa);
assert_eq!(range_fa, psf.f_a(&a, &preimage))Source§fn f_a(&self, a: &MatZq, sigma: &MatZ) -> MatZq
fn f_a(&self, a: &MatZq, sigma: &MatZ) -> MatZq
Implements the efficiently computable function f_a which here corresponds to
a*sigma. The sigma must be from the domain, i.e. D_n.
Parameters:
a: The parity-check matrix of dimensionsn x msigma: A column vector of lengthm
Returns a*sigma
§Examples
use qfall_tools::primitive::psf::PSFGPV;
use qfall_tools::sample::g_trapdoor::gadget_parameters::GadgetParameters;
use qfall_math::rational::Q;
use qfall_tools::primitive::psf::PSF;
let psf = PSFGPV {
gp: GadgetParameters::init_default(8, 64),
s: Q::from(12),
};
let (a, td) = psf.trap_gen();
let domain_sample = psf.samp_d();
let range_fa = psf.f_a(&a, &domain_sample);§Panics …
- if
sigmais not in the domain.
Source§fn check_domain(&self, sigma: &MatZ) -> bool
fn check_domain(&self, sigma: &MatZ) -> bool
Checks whether a value sigma is in D_n = {e ∈ Z^m | |e| <= s sqrt(m)}.
Parameters:
sigma: The value for which is checked, if it is in the domain
Returns true, if sigma is in D_n.
§Examples
use qfall_tools::primitive::psf::PSF;
use qfall_tools::primitive::psf::PSFGPV;
use qfall_tools::sample::g_trapdoor::gadget_parameters::GadgetParameters;
use qfall_math::rational::Q;
let psf = PSFGPV {
gp: GadgetParameters::init_default(8, 64),
s: Q::from(12),
};
let (a, td) = psf.trap_gen();
let vector = psf.samp_d();
assert!(psf.check_domain(&vector));