crypto

package
v0.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodePrivateKey

func DecodePrivateKey(s string) (ed25519.PrivateKey, error)

DecodePrivateKey decodes a base64 private key.

func DecodePublicKey

func DecodePublicKey(s string) (ed25519.PublicKey, error)

DecodePublicKey decodes a base64 public key.

func EncodePrivateKey

func EncodePrivateKey(key ed25519.PrivateKey) string

EncodePrivateKey returns the private key as base64.

func EncodePublicKey

func EncodePublicKey(key ed25519.PublicKey) string

EncodePublicKey returns the public key as base64.

func SaveIdentity

func SaveIdentity(path string, id *Identity) error

SaveIdentity writes the identity keypair to a JSON file. Creates parent directories if needed. File is written with mode 0600.

func Verify

func Verify(publicKey ed25519.PublicKey, message, signature []byte) bool

Verify checks a signature against the public key.

Types

type Identity

type Identity struct {
	PublicKey  ed25519.PublicKey
	PrivateKey ed25519.PrivateKey
}

Identity holds an Ed25519 keypair for a node.

func GenerateIdentity

func GenerateIdentity() (*Identity, error)

GenerateIdentity creates a new random Ed25519 keypair.

func LoadIdentity

func LoadIdentity(path string) (*Identity, error)

LoadIdentity reads an identity keypair from a JSON file. Returns nil, nil if the file does not exist (first run).

Emits a WARN (does NOT refuse) when the file's mode permits group or other access. The identity file contains the Ed25519 private key; SaveIdentity always writes 0o600, but an operator who created the file by hand or restored from a permissive backup can end up with 0o644 — group/other readable. The warning gives them a signal to chmod 600 without breaking existing deployments. A future release can promote the warning to a refusal once the fleet has had a release cycle to tighten permissions.

func (*Identity) Sign

func (id *Identity) Sign(message []byte) []byte

Sign signs a message with the private key.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL