Skip to main content

load_or_generate_node_keypair

Function load_or_generate_node_keypair 

Source
pub fn load_or_generate_node_keypair(
    base_dir: &Path,
) -> Result<(RecipientPrivateKey, RecipientPublicKey), SecretsError>
Expand description

Load the existing node keypair from {base_dir}/node_secrets.key, or generate a new one and persist it (Unix mode 0600) if the file does not exist yet.

Returns (private, public). The private key is held in RecipientPrivateKey which zeroes itself on drop.

ยงErrors

  • SecretsError::Storage if the directory cannot be created, the file cannot be read/written, or the on-disk content is the wrong length (must be exactly 32 bytes).
  • SecretsError::Storage if file permissions cannot be set on Unix.