View Source NKEYS.Keypair (nkeys v0.3.0)

Contains functions for creating, manipulating, and interacting with key pairs

Summary

Functions

Creates a new keypair from a string-encoded public key. Note that this keypair will not have a private key and as such won't be able to sign or encrypt

Creates a new key pair from an encoded seed string ('S' prefix)

Creates a new key pair used for identifying an account (prefix 'A')

Creates a new key pair used for identifying a cluster (prefix 'C')

Creates a new key pair used for identifying a system operator (prefix 'O')

Creates a new key pair used for identifying a server (prefix 'N')

Creates a new key pair used for identifying a user (prefix 'U')

Creates a new key pair used for ed25519 encryption (prefix 'X')

Extracts the human-friendly, string-encoded public key from the keypair

Signs a message with the given key pair. Note that the key pair must have a private key in order to create the signature.

Types

@type t() :: %NKEYS.Keypair{
  prefix: byte(),
  private_key: binary(),
  public_key: binary(),
  seed: String.t()
}

Functions

@spec from_public(binary()) :: :error | t()

Creates a new keypair from a string-encoded public key. Note that this keypair will not have a private key and as such won't be able to sign or encrypt

@spec from_seed(seed :: binary()) :: {:ok, t()} | {:error, :invalid_seed}

Creates a new key pair from an encoded seed string ('S' prefix)

@spec new_account() :: t()

Creates a new key pair used for identifying an account (prefix 'A')

@spec new_cluster() :: t()

Creates a new key pair used for identifying a cluster (prefix 'C')

@spec new_operator() :: t()

Creates a new key pair used for identifying a system operator (prefix 'O')

@spec new_server() :: t()

Creates a new key pair used for identifying a server (prefix 'N')

@spec new_user() :: t()

Creates a new key pair used for identifying a user (prefix 'U')

@spec new_xkey() :: t()

Creates a new key pair used for ed25519 encryption (prefix 'X')

@spec public_key(t()) :: String.t()

Extracts the human-friendly, string-encoded public key from the keypair

@spec sign(keypair :: t(), message :: binary()) :: binary()

Signs a message with the given key pair. Note that the key pair must have a private key in order to create the signature.