pub struct Keypair { /* private fields */ }Expand description
An Ed25519 keypair held in memory. The secret key is [u8; 32]
— the 32-byte seed Ed25519 expands into a signing key. We never
keep the expanded scalar around; every sign call regenerates it
from the seed.
Implementations§
Source§impl Keypair
impl Keypair
Sourcepub fn generate() -> Result<Self, SigningError>
pub fn generate() -> Result<Self, SigningError>
Generate a fresh keypair using the OS CSPRNG. Suitable for
lex keygen; production callers wanting deterministic keys
(test vectors, KAT) should use Keypair::from_secret_hex.
Sourcepub fn from_seed(seed: &[u8; 32]) -> Self
pub fn from_seed(seed: &[u8; 32]) -> Self
Build a keypair from a 32-byte seed. Useful for tests where a
known fixture key is needed; production callers should prefer
Keypair::generate or the hex-deserialise path.
Sourcepub fn from_secret_hex(hex_str: &str) -> Result<Self, SigningError>
pub fn from_secret_hex(hex_str: &str) -> Result<Self, SigningError>
Parse a hex-encoded 32-byte secret key (the seed).
Sourcepub fn secret_hex(&self) -> String
pub fn secret_hex(&self) -> String
Lowercase-hex of the 32-byte secret seed. Treat as material —
this is what lex keygen prints to stdout exactly once.
Sourcepub fn public_hex(&self) -> String
pub fn public_hex(&self) -> String
Lowercase-hex of the 32-byte public key. Safe to publish.
Sourcepub fn sign_stage_id(&self, stage_id: &str) -> Signature
pub fn sign_stage_id(&self, stage_id: &str) -> Signature
Sign the UTF-8 bytes of a StageId and return the wire-format
Signature record. The same record verifies via
verify_stage_id.