p2p

package
v1.3.2-rc.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: MIT, MIT Imports: 9 Imported by: 0

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