initcmd

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Seed = "key.seed"
	Pub  = "key.pub"
)

Variables

View Source
var Cmd = &cli.Subcmd{
	FlagSet: flag.NewFlagSet("init", flag.ExitOnError),
	Desc:    "Generate ed25519 keypair (key.seed, key.pub) and exit",
	Run: func(fm fsdir.T) {
		pk, sk, err := ed25519.GenerateKey(nil)

		if err != nil {
			log.Fatal(err)
		}

		log.Printf("writing ed25519 private key seed to %s", fm.Path(Seed))
		err = fm.Set(jsonb.B(sk.Seed()), Seed)

		if err != nil {
			log.Fatal(err)
		}

		err = fm.Chmod(0600, Seed)

		if err != nil {
			log.Fatal(err)
		}

		log.Printf("writing ed25519 public key to %s", fm.Path(Pub))
		err = fm.Set(jsonb.PK(pk), Pub)

		if err != nil {
			log.Fatal(err)
		}
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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