PSFGPVRing

Struct PSFGPVRing 

Source
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 generated
  • s: The Gaussian parameter with which elements from the domain are sampled
  • s: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: Q

Trait Implementations§

Source§

impl<'de> Deserialize<'de> for PSFGPVRing

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PSF for PSFGPVRing

Source§

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

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

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 matrix
  • r: Together with e builds a G-Trapdoor for a
  • e: Together with r builds a G-Trapdoor for a
  • u: 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

Implements the efficiently computable function f_a which here corresponds to a*sigma.

Parameters:

  • a: The parity-check matrix of dimensions n x m
  • sigma: A column vector of length m

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 sigma is not in the domain.
Source§

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));
Source§

type A = MatPolynomialRingZq

Source§

type Trapdoor = (MatPolyOverZ, MatPolyOverZ)

Source§

type Domain = MatPolyOverZ

Source§

type Range = MatPolynomialRingZq

Source§

impl Serialize for PSFGPVRing

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,