pub struct SecretKey { /* private fields */ }
Expand description
Represents the secret key for Falcon DSA.
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 is 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:
- h = g /f [mod ϕ][mod p]
- 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
impl SecretKey
sourcepub fn with_rng<R: Rng>(rng: &mut R) -> Self
pub fn with_rng<R: Rng>(rng: &mut R) -> Self
Generates a secret_key using the provided random number generator Rng
.
sourcepub fn short_lattice_basis(&self) -> &[Polynomial<i16>; 4]
pub fn short_lattice_basis(&self) -> &[Polynomial<i16>; 4]
Returns the polynomials of the short lattice basis of this secret key.
sourcepub fn public_key(&self) -> PublicKey
pub fn public_key(&self) -> PublicKey
Returns the public key corresponding to this secret key.
sourcepub fn sign_with_rng<R: Rng>(&self, message: Word, rng: &mut R) -> Signature
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.
sourcepub fn compute_pub_key_poly(&self) -> PubKeyPoly
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 Deserializable for SecretKey
impl Deserializable for SecretKey
source§fn read_from<R: ByteReader>(
source: &mut R,
) -> Result<Self, DeserializationError>
fn read_from<R: ByteReader>( source: &mut R, ) -> Result<Self, DeserializationError>
source
, attempts to deserialize these bytes
into Self
, and returns the result. Read moresource§fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
source§impl Serializable for SecretKey
impl Serializable for SecretKey
source§fn write_into<W: ByteWriter>(&self, target: &mut W)
fn write_into<W: ByteWriter>(&self, target: &mut W)
self
into bytes and writes these bytes into the target
.source§fn get_size_hint(&self) -> usize
fn get_size_hint(&self) -> usize
Auto Trait Implementations§
impl Freeze for SecretKey
impl RefUnwindSafe for SecretKey
impl Send for SecretKey
impl Sync for SecretKey
impl Unpin for SecretKey
impl UnwindSafe for SecretKey
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)