p2p

package
v1.20.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT, MIT Imports: 9 Imported by: 5 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Subcommands = cli.Commands{
	{
		Name:  "priv2id",
		Usage: "Reads a private key from STDIN, and returns a peer ID",
		Action: func(ctx *cli.Context) error {
			key, err := Priv2PeerID(os.Stdin)
			if err != nil {
				return err
			}
			fmt.Println(key)
			return nil
		},
	},
	{
		Name:  "pub2id",
		Usage: "Reads a public key from STDIN, and returns a peer ID",
		Action: func(ctx *cli.Context) error {
			key, err := Pub2PeerID(os.Stdin)
			if err != nil {
				return err
			}
			fmt.Println(key)
			return nil
		},
	},
	{
		Name:  "genkey",
		Usage: "Generates a private key",
		Action: func(ctx *cli.Context) error {
			buf := make([]byte, 32)
			if _, err := rand.Read(buf); err != nil {
				return fmt.Errorf("failed to get entropy: %w", err)
			}
			fmt.Println(hex.EncodeToString(buf))
			return nil
		},
	},
}

Functions

func Priv2PeerID

func Priv2PeerID(r io.Reader) (string, error)

func Pub2PeerID

func Pub2PeerID(r io.Reader) (string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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