Skip to content

keygen

Structs

Enums

Functions

  • write_keypair - Generate a fresh Ed25519 (PASETO v4) keypair and write it to disk.

Enum

Failure modes for [write_keypair].

Variants:

  • Generate(String) - PASETO keypair generation failed.
  • Write{ path: std::path::PathBuf, source: std::io::Error } - Writing the secret or public key file failed.

Trait Implementations:

  • Display
    • fn fmt(self: &Self, __formatter: & mut ::core::fmt::Formatter) -> ::core::fmt::Result
  • Error
    • fn source(self: &Self) -> ::core::option::Option<&dyn ::thiserror::__private18::Error>
  • Debug
    • fn fmt(self: &Self, f: & mut $crate::fmt::Formatter) -> $crate::fmt::Result

Struct

Paths written by [write_keypair].

Fields:

  • secret: std::path::PathBuf - Secret key file (the input path).
  • public: std::path::PathBuf - Public key file (path with a .pub extension).

Traits: Eq

Trait Implementations:

  • PartialEq
    • fn eq(self: &Self, other: &KeypairPaths) -> bool
  • Clone
    • fn clone(self: &Self) -> KeypairPaths
  • Debug
    • fn fmt(self: &Self, f: & mut $crate::fmt::Formatter) -> $crate::fmt::Result

Function

Generate a fresh Ed25519 (PASETO v4) keypair and write it to disk.

path receives the secret key; the public key is written alongside it at path with the extension replaced by .pub. Both files are created with create_new so an existing key is never silently overwritten — callers that want to reuse an existing key must check for it first.

On Unix the secret is mode 0o600 and the public key 0o644.

  • [KeygenError::Generate] when keypair generation fails.
  • [KeygenError::Write] when either file cannot be created or written.
fn write_keypair(path: &std::path::Path) -> Result<KeypairPaths, KeygenError>