pub struct ClusterSigner { /* private fields */ }Expand description
Ed25519 keypair used to sign cluster join tokens.
Cloning is intentionally not implemented: each ClusterSigner owns its
signing material and should be passed by reference through the daemon
(typically Arc<ClusterSigner>).
Implementations§
Source§impl ClusterSigner
impl ClusterSigner
Sourcepub fn generate() -> Self
pub fn generate() -> Self
Generate a fresh keypair from the OS CSPRNG.
The seed is drawn directly from the OS via rand::rngs::OsRng
(workspace rand 0.9) and fed to SigningKey::from_bytes. We avoid
SigningKey::generate here because ed25519-dalek 2.x requires
rand_core 0.6’s CryptoRngCore trait, while the workspace pins
rand 0.9 (whose OsRng implements rand_core 0.9’s TryRngCore).
Filling 32 bytes via the workspace rand is equivalent: an Ed25519
signing key is just 32 random bytes.
§Panics
Panics if the OS CSPRNG fails. This matches the behavior of
SigningKey::generate(&mut OsRng) and is appropriate because key
generation cannot proceed without entropy.
Sourcepub async fn load_or_generate(path: &Path) -> Result<Self, SecretsError>
pub async fn load_or_generate(path: &Path) -> Result<Self, SecretsError>
Load the keypair from the on-disk keystore at path if present;
otherwise generate a fresh one, persist it as a JSON keystore with
mode 0600, and return it. Returns the ClusterSigner for the
currently-active key.
If the file exists in the legacy raw-32-byte format (Wave 1), it is transparently migrated to the JSON keystore layout in place. The migration is idempotent.
The parent directory of path is created if it does not exist
(mkdir -p semantics).
§Errors
SecretsError::Storageif the parent directory cannot be created, if the file cannot be read or written, or if the file exists but is neither valid keystore JSON nor a 32-byte legacy seed.SecretsError::Storageif Unix file permissions cannot be set.
Sourcepub fn verifying_key(&self) -> VerifyingKey
pub fn verifying_key(&self) -> VerifyingKey
The public verifying key.
Sourcepub fn public_key_b64(&self) -> String
pub fn public_key_b64(&self) -> String
URL-safe no-pad base64 of the 32-byte verifying key.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ClusterSigner
impl RefUnwindSafe for ClusterSigner
impl Send for ClusterSigner
impl Sync for ClusterSigner
impl Unpin for ClusterSigner
impl UnsafeUnpin for ClusterSigner
impl UnwindSafe for ClusterSigner
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more