pub struct Ed25519Signer { /* private fields */ }Expand description
In-process Ed25519 signer.
Implementations§
Source§impl Ed25519Signer
impl Ed25519Signer
Sourcepub fn generate() -> Self
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.
Sourcepub fn from_seed(seed: &[u8; 32]) -> Self
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.