identity

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package identity manages libp2p node identity keys on disk.

Index

Constants

View Source
const KeyFilename = "p2p.key"

Variables

This section is empty.

Functions

func EnsureIdentity

func EnsureIdentity(dir string, opt ...Option) (crypto.PrivKey, error)

EnsureIdentity generates an identity key file in given directory.

func GenIdentityEd25519

func GenIdentityEd25519() (crypto.PrivKey, error)

GenIdentityEd25519 creates a new random Ed25519 private key.

func GenerateIdentitySecp256k1

func GenerateIdentitySecp256k1() (crypto.PrivKey, error)

GenerateIdentitySecp256k1 creates a new random Secp256k1 private key.

Types

type IdentityInfo

type IdentityInfo struct {
	Key []byte
	ID  peer.ID // this is needed only to simplify integration with some testing tools
}

IdentityInfo contains the serialized private key and peer ID. The ID field is included to simplify integration with testing tools.

func ExtractIdentityFromDir

func ExtractIdentityFromDir(dir string) (*IdentityInfo, error)

ExtractIdentityFromDir loads an existing identity from the specified directory. Returns an error if the identity file does not exist or cannot be read/parsed.

type Option

type Option func() (crypto.PrivKey, error)

Option is a function that generates a private key. Used to customize key generation in EnsureIdentity.

Jump to

Keyboard shortcuts

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