Skip to main content

HybridSigningKey

Struct HybridSigningKey 

Source
pub struct HybridSigningKey {
    pub ed25519_sk: SigningKey,
    pub ml_dsa_sk: Box<SigningKey<MlDsa65>>,
}
Expand description

Hybrid signing key — Ed25519 + ML-DSA-65 secret material.

On drop, both halves are zeroed: ed25519_dalek::SigningKey carries its own Drop impl (via the zeroize feature enabled in Cargo.toml), and ml_dsa::SigningKey<P> implements ZeroizeOnDrop natively. The pre-Phase-5.1 unsafe ptr::write_volatile wrapper in crypto::keys is no longer needed and was deleted.

ml_dsa_sk is Box-ed because SigningKey<MlDsa65> internally embeds the ~4 KiB ExpandedSigningKey by value; placing the whole thing on the stack at every construction would overflow default tokio test threads (the from_seed call alone constructs a large temporary). On the heap it’s a single pointer-sized field at our level; Box<T: ZeroizeOnDrop> correctly forwards Drop to T.

Fields§

§ed25519_sk: SigningKey§ml_dsa_sk: Box<SigningKey<MlDsa65>>

Implementations§

Source§

impl HybridSigningKey

Source

pub fn generate() -> (Self, HybridVerifyingKey)

Generate a fresh hybrid keypair using the OS RNG.

Equivalent to Self::generate_with_provider(&crate::crypto::rng::OsRng). Preserved as the call-compatible default so the rest of the crate (and downstream callers) does not change shape.

Source

pub fn generate_with_provider<R: RngProvider + ?Sized>( provider: &R, ) -> (Self, HybridVerifyingKey)

Generate a fresh hybrid keypair using an arbitrary RngProvider.

Phase 3.8 demonstration of the RngProvider indirection: this is the canonical “small, well-bounded crypto entry point that needs randomness” call site. Embedders that need to drive key generation from a hardware TRNG (on no_std) or a FIPS-approved DRBG plug in here without disturbing the default surface.

Internally, 32 bytes are drawn from the provider for each algorithm:

  • Ed25519: the 32 bytes are the seed for SigningKey::from_bytes.
  • ML-DSA-65: the 32 bytes are the FIPS 204 § Algorithm 1 seed xi passed to SigningKey::<MlDsa65>::new(&seed) (== KeyInit / from_seed).
Source

pub fn pairwise_consistency_check( &self, verifying_key: &HybridVerifyingKey, ) -> Result<(), HybridSignError>

FIPS 140-3 §7.10 pairwise-consistency test for a freshly-generated long-term hybrid signing identity: sign a fixed message with this secret key and verify it against verifying_key. Returns Err iff the keypair cannot validate its own signature — i.e. the RNG or a signing primitive was faulted and the key must not be used.

Call this only at persisted / long-lived-identity generation sites (CLI keygen, server identity load-or-create, PhantomListener::bind). It is deliberately not run inside generate / generate_with_provider: those mint the client’s ephemeral per-handshake signing key, and a sign+verify there would add ~40% to every client handshake. The requirement targets long-term keypairs, not per-connection ephemerals.

Source

pub fn sign(&self, message: &[u8]) -> HybridSignature

Sign with both algorithms. Both signatures are returned in the HybridSignature; verification on the peer side requires both to be valid.

Source

pub fn verifying_key(&self) -> HybridVerifyingKey

Source

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

Serialize the signing key as (ed25519_seed[32] || ml_dsa_seed[32]). ML-DSA-65 is fully derivable from its 32-byte seed (per FIPS 204 KeyGen algorithm) so we store the compact form rather than the 4032-byte expanded representation.

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self, HybridSignError>

Restore from to_bytes output.

Trait Implementations§

Source§

impl Debug for HybridSigningKey

Source§

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

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

impl Drop for HybridSigningKey

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CompatExt for T

Source§

fn compat(self) -> Compat<T>
where T: Sized,

Applies the Compat adapter by value. Read more
Source§

fn compat_ref(&self) -> Compat<&T>

Applies the Compat adapter by shared reference. Read more
Source§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the Compat adapter by mutable reference. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

Source§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
Source§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
Source§

unsafe fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<> Read more
Source§

unsafe fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more