pub struct PSFGPVRing {
pub gp: GadgetParametersRing,
pub s: Q,
pub s_td: Q,
}Expand description
A lattice-based implementation of a PSF according to
[1] and [2]
using G-Trapdoors where D_n = {e ∈ R^m | |ι(e)| <= s sqrt(m*n) }
and R_n = R_q.
Attributes
gp: Describes the gadget parameters with which the G-Trapdoor is generateds: The Gaussian parameter with which elements from the domain are sampleds:td: The Gaussian parameter with which the trapdoor is sampled
§Examples
use qfall_tools::primitive::psf::PSFGPVRing;
use qfall_tools::sample::g_trapdoor::gadget_parameters::GadgetParametersRing;
use qfall_math::rational::Q;
use qfall_tools::primitive::psf::PSF;
let psf = PSFGPVRing {
gp: GadgetParametersRing::init_default(8, 512),
s: Q::from(100),
s_td: Q::from(1.005_f64),
};
let (a, (r, e)) = psf.trap_gen();
let domain_sample = psf.samp_d();
let range_fa = psf.f_a(&a, &domain_sample);
let preimage = psf.samp_p(&a, &(r,e), &range_fa);
assert!(psf.check_domain(&preimage));Fields§
§gp: GadgetParametersRing§s: Q§s_td: QTrait Implementations§
Source§impl<'de> Deserialize<'de> for PSFGPVRing
impl<'de> Deserialize<'de> for PSFGPVRing
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 PSFGPVRing
impl PSF for PSFGPVRing
Source§fn trap_gen(&self) -> (MatPolynomialRingZq, (MatPolyOverZ, MatPolyOverZ))
fn trap_gen(&self) -> (MatPolynomialRingZq, (MatPolyOverZ, MatPolyOverZ))
Computes a G-Trapdoor according to the GadgetParametersRing.
§Examples
use qfall_tools::primitive::psf::PSFGPVRing;
use qfall_tools::sample::g_trapdoor::gadget_parameters::GadgetParametersRing;
use qfall_math::rational::Q;
use qfall_tools::primitive::psf::PSF;
let psf = PSFGPVRing {
gp: GadgetParametersRing::init_default(8, 512),
s: Q::from(100),
s_td: Q::from(1.005_f64),
};
let (a, (r, e)) = psf.trap_gen();Source§fn samp_d(&self) -> MatPolyOverZ
fn samp_d(&self) -> MatPolyOverZ
Samples in the domain using SampleD with the standard basis and center 0.
§Examples
use qfall_tools::primitive::psf::PSFGPVRing;
use qfall_tools::sample::g_trapdoor::gadget_parameters::GadgetParametersRing;
use qfall_math::rational::Q;
use qfall_tools::primitive::psf::PSF;
let psf = PSFGPVRing {
gp: GadgetParametersRing::init_default(8, 512),
s: Q::from(100),
s_td: Q::from(1.005_f64),
};
let (a, (r, e)) = psf.trap_gen();
let domain_sample = psf.samp_d();Source§fn samp_p(
&self,
a: &MatPolynomialRingZq,
(r, e): &(MatPolyOverZ, MatPolyOverZ),
u: &MatPolynomialRingZq,
) -> MatPolyOverZ
fn samp_p( &self, a: &MatPolynomialRingZq, (r, e): &(MatPolyOverZ, MatPolyOverZ), u: &MatPolynomialRingZq, ) -> MatPolyOverZ
Samples an e in the domain using SampleD with a short basis that is generated
from the G-Trapdoor from the conditioned discrete Gaussian with
f_a(a,e) = u for a provided syndrome u.
Note: the provided parameters a, r, e, u must fit together,
otherwise unexpected behavior such as panics may occur.
Parameters:
a: The parity-check matrixr: Together withebuilds a G-Trapdoor forae: Together withrbuilds a G-Trapdoor forau: 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::PSFGPVRing;
use qfall_tools::sample::g_trapdoor::gadget_parameters::GadgetParametersRing;
use qfall_math::rational::Q;
use qfall_tools::primitive::psf::PSF;
let psf = PSFGPVRing {
gp: GadgetParametersRing::init_default(8, 512),
s: Q::from(100),
s_td: Q::from(1.005_f64),
};
let (a, (r, e)) = psf.trap_gen();
let domain_sample = psf.samp_d();
let range_fa = psf.f_a(&a, &domain_sample);
let preimage = psf.samp_p(&a, &(r,e), &range_fa);
assert_eq!(range_fa, psf.f_a(&a, &preimage))Source§fn f_a(
&self,
a: &MatPolynomialRingZq,
sigma: &MatPolyOverZ,
) -> MatPolynomialRingZq
fn f_a( &self, a: &MatPolynomialRingZq, sigma: &MatPolyOverZ, ) -> MatPolynomialRingZq
Implements the efficiently computable function f_a which here corresponds to
a*sigma.
Parameters:
a: The parity-check matrix of dimensionsn x msigma: A column vector of lengthm
Returns a*sigma
§Examples
use qfall_tools::primitive::psf::PSFGPVRing;
use qfall_tools::sample::g_trapdoor::gadget_parameters::GadgetParametersRing;
use qfall_math::rational::Q;
use qfall_tools::primitive::psf::PSF;
let psf = PSFGPVRing {
gp: GadgetParametersRing::init_default(8, 512),
s: Q::from(100),
s_td: Q::from(1.005_f64),
};
let (a, (r, e)) = 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: &MatPolyOverZ) -> bool
fn check_domain(&self, sigma: &MatPolyOverZ) -> bool
Checks whether a value sigma is in D_n = {e ∈ R^m | |ι(e)| <= s sqrt(m*n) }.
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::PSFGPVRing;
use qfall_tools::sample::g_trapdoor::gadget_parameters::GadgetParametersRing;
use qfall_math::rational::Q;
use qfall_tools::primitive::psf::PSF;
let psf = PSFGPVRing {
gp: GadgetParametersRing::init_default(8, 512),
s: Q::from(100),
s_td: Q::from(1.005_f64),
};
let (a, (r, e)) = psf.trap_gen();
let vector = psf.samp_d();
assert!(psf.check_domain(&vector));