Skip to main content

FnDsaKeyPair

Struct FnDsaKeyPair 

Source
pub struct FnDsaKeyPair { /* private fields */ }
Expand description

An FN-DSA key pair (private key + public key).

Use logn = 9 for FN-DSA-512 (NIST Level I) or logn = 10 for FN-DSA-1024 (NIST Level V).

The private key bytes are automatically zeroized on drop.

Note: Clone duplicates private key material in memory. Only clone when you need multiple owners; prefer references otherwise.

Implementations§

Source§

impl FnDsaKeyPair

Source

pub fn generate(logn: u32) -> Result<Self, FalconError>

Generate a new FN-DSA key pair using OS entropy.

  • logn — 9 for FN-DSA-512, 10 for FN-DSA-1024.
Source

pub fn generate_deterministic( seed: &[u8], logn: u32, ) -> Result<Self, FalconError>

Generate a key pair deterministically from seed.

Source

pub fn from_keys(privkey: &[u8], pubkey: &[u8]) -> Result<Self, FalconError>

Reconstruct from previously exported private + public key bytes.

Source

pub fn from_private_key(privkey: &[u8]) -> Result<Self, FalconError>

Reconstruct from a private key only (public key is recomputed).

Source

pub fn public_key_from_private(privkey: &[u8]) -> Result<Vec<u8>, FalconError>

Compute the public key bytes from a private key without creating a key pair.

Source

pub fn sign( &self, message: &[u8], domain: &DomainSeparation<'_>, ) -> Result<FnDsaSignature, FalconError>

Sign message using FIPS 206 domain separation.

Supports both pure FN-DSA (DomainSeparation::None / DomainSeparation::Context) and HashFN-DSA (DomainSeparation::Prehashed).

§Errors
Source

pub fn sign_deterministic( &self, message: &[u8], seed: &[u8], domain: &DomainSeparation<'_>, ) -> Result<FnDsaSignature, FalconError>

Sign with a deterministic seed (testing / reproducibility).

The same (key, message, seed, domain) tuple always produces the same signature.

§Errors
Source

pub fn public_key(&self) -> &[u8]

Get the encoded public key bytes.

Source

pub fn private_key(&self) -> &[u8]

Get the encoded private key bytes.

⚠️ Secret material — handle with care.

Source

pub fn logn(&self) -> u32

Get the FN-DSA degree parameter.

Returns 9 for FN-DSA-512, 10 for FN-DSA-1024.

Source

pub fn variant_name(&self) -> &'static str

Get the security variant name.

Source§

impl FnDsaKeyPair

Source

pub fn expand(&self) -> Result<FnDsaExpandedKey, FalconError>

Expand the private key into a precomputed signing tree.

The resulting FnDsaExpandedKey is ~1.5× faster per sign operation at the cost of a one-time expansion (~2.5× a single sign).

Trait Implementations§

Source§

impl Clone for FnDsaKeyPair

Source§

fn clone(&self) -> FnDsaKeyPair

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for FnDsaKeyPair

Source§

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

Formats the value using the given formatter. 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, dest: *mut u8)

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