PSFGPV

Struct PSFGPV 

Source
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 generated
  • s: 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: Q

Trait Implementations§

Source§

impl<'de> Deserialize<'de> for PSFGPV

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 PSFGPV

Source§

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

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

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 matrix
  • short_base: The short base for Λ^⟂(A)
  • short_base_gso: The precomputed GSO of the short_base
  • 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::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

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 dimensions n x m
  • sigma: A column vector of length m

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

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

type A = MatZq

Source§

type Trapdoor = (MatZ, MatQ)

Source§

type Domain = MatZ

Source§

type Range = MatZq

Source§

impl Serialize for PSFGPV

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§

§

impl Freeze for PSFGPV

§

impl !RefUnwindSafe for PSFGPV

§

impl !Send for PSFGPV

§

impl !Sync for PSFGPV

§

impl Unpin for PSFGPV

§

impl !UnwindSafe for PSFGPV

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>,