miden_crypto::dsa::rpo_falcon512

Struct SecretKey

source
pub struct SecretKey { /* private fields */ }
Expand description

The secret key is a quadruple [[g, -f], [G, -F]] of polynomials with integer coefficients.

Each polynomial is of degree at most N = 512 and computations with these polynomials are done modulo the monic irreducible polynomial ϕ = x^N + 1. The secret key is a basis for a lattice and has the property of being short with respect to a certain norm and an upper bound appropriate for a given security parameter. The public key on the other hand is another basis for the same lattice and can be described by a single polynomial h with integer coefficients modulo ϕ. The two keys are related by the following relation:

  1. h = g /f [mod ϕ][mod p]
  2. f.G - g.F = p [mod ϕ]

where p = 12289 is the Falcon prime. Equation 2 is called the NTRU equation. The secret key is generated by first sampling a random pair (f, g) of polynomials using an appropriate distribution that yields short but not too short polynomials with integer coefficients modulo ϕ. The NTRU equation is then used to find a matching pair (F, G). The public key is then derived from the secret key using equation 1.

To allow for fast signature generation, the secret key is pre-processed into a more suitable form, called the LDL tree, and this allows for fast sampling of short vectors in the lattice using Fast Fourier sampling during signature generation (ffSampling algorithm 11 in 1).

Implementations§

source§

impl SecretKey

source

pub fn new() -> Self

Generates a secret key from OS-provided randomness.

source

pub fn with_rng<R: Rng>(rng: &mut R) -> Self

Generates a secret_key using the provided random number generator Rng.

source

pub fn short_lattice_basis(&self) -> &[Polynomial<i16>; 4]

Returns the polynomials of the short lattice basis of this secret key.

source

pub fn public_key(&self) -> PublicKey

Returns the public key corresponding to this secret key.

source

pub fn tree(&self) -> &LdlTree

Returns the LDL tree associated to this secret key.

source

pub fn sign(&self, message: Word) -> Signature

Signs a message with this secret key.

source

pub fn sign_with_rng<R: Rng>(&self, message: Word, rng: &mut R) -> Signature

Signs a message with the secret key relying on the provided randomness generator.

source

pub fn compute_pub_key_poly(&self) -> PubKeyPoly

Derives the public key corresponding to this secret key using h = g /f [mod ϕ][mod p].

Trait Implementations§

source§

impl Clone for SecretKey

source§

fn clone(&self) -> SecretKey

Returns a copy of the value. Read more
1.6.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SecretKey

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Deserializable for SecretKey

source§

fn read_from<R: ByteReader>( source: &mut R, ) -> Result<Self, DeserializationError>

Reads a sequence of bytes from the provided source, attempts to deserialize these bytes into Self, and returns the result. Read more
source§

fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>

Attempts to deserialize the provided bytes into Self and returns the result. Read more
source§

impl Serializable for SecretKey

source§

fn write_into<W: ByteWriter>(&self, target: &mut W)

Serializes self into bytes and writes these bytes into the target.
source§

fn to_bytes(&self) -> Vec<u8>

Serializes self into a vector of bytes.
source§

fn get_size_hint(&self) -> usize

Returns an estimate of how many bytes are needed to represent self. 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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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