Skip to main content

Keypair

Struct Keypair 

Source
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

Source

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.

Source

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.

Source

pub fn from_secret_hex(hex_str: &str) -> Result<Self, SigningError>

Parse a hex-encoded 32-byte secret key (the seed).

Source

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.

Source

pub fn public_hex(&self) -> String

Lowercase-hex of the 32-byte public key. Safe to publish.

Source

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.

Trait Implementations§

Source§

impl Debug for Keypair

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