crypto

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: AGPL-3.0 Imports: 7 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).

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