Skip to main content

Ed25519Signer

Struct Ed25519Signer 

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

In-process Ed25519 signer.

Implementations§

Source§

impl Ed25519Signer

Source

pub fn generate() -> Self

Generate a fresh keypair. The key id is derived from the public key (first 32 hex chars of its SHA-256) so ids are collision-resistant and never chosen by an attacker.

Defense-in-depth against a compromised getrandom (VM without entropy, cloud image with a broken /dev/urandom) — regenerate rather than accept an all-zero or all-0xFF seed. Reader-side already refuses these known-weak seeds; this closes the gap for generator-side. Astronomically unlikely from a healthy OsRng, but the failure mode is silent installation of a globally-predictable keypair — cheap to guard.

Source

pub fn from_seed(seed: &[u8; 32]) -> Self

Load from a 32-byte secret seed.

Takes &[u8; 32] (borrow), not by value. Passing the seed by value materializes a caller-owned temp slot on the stack that Rust does not guarantee to zeroize on drop — a Zeroizing<[u8; 32]> wrapper only zeroizes the slot IT owns, not the copy the callee received. By taking a reference we let the caller keep the seed inside a Zeroizing and never lose control of the memory.

§Caveat: caller must reject known-weak seeds

This constructor does NOT reject the all-zero or all-0xFF seeds (both produce globally-predictable keypairs). The production seed-loading path in av-harness::main::read_signer refuses both before reaching this function (see the [0u8; 32] / [0xFFu8; 32] guard in av-harness/src/main.rs); every OTHER caller (tests, avctl keygen) must apply the same policy or use Ed25519Signer::generate which loops until a non-weak seed is drawn. This contract is documented in-signature so a future refactor cannot silently drop the pre-validation.

Source

pub fn seed(&self) -> Zeroizing<[u8; 32]>

Export the 32-byte secret seed (for avctl keygen persistence).

Returns Zeroizing<[u8; 32]> so the caller’s receiving slot zeroes on drop — historically the bare [u8; 32] return let a copy linger in freed stack/heap.

Trait Implementations§

Source§

impl Debug for Ed25519Signer

Source§

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

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

impl Signer for Ed25519Signer

Source§

fn key_id(&self) -> &str

Stable identifier for the signing key (embedded in receipts).
Source§

fn sign(&self, msg: &[u8]) -> [u8; 64]

Sign msg, returning the 64-byte Ed25519 signature.
Source§

fn public_key_bytes(&self) -> [u8; 32]

The corresponding public key (32 bytes).

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> 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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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