p2p

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: MIT Imports: 9 Imported by: 2

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