All checks were successful
check / check (push) Successful in 2m38s
The application number is 657169, so the path is m/83696968'/657169'/<n>'. The 32 derived bytes are clamped the way X25519 requires and go through bech32 into an age identity, the only route age offers from raw bytes to a key; these are the steps sneak/secret takes in its agehd package. A test fixes the secret key the example mnemonic gives at index 0, so a change to any of those steps is caught. The derived recipient is always first, so the mnemonic that encrypted a file can read it back. Decrypting recognises the text form by its first line, so it needs no flag. A file named with -o is written beside the target, readable only by its owner, and renamed into place once the work succeeds, so a refused decryption leaves what was already there untouched. Model: opus-5
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
// Package cli builds the command tree and runs it.
|
|
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"git.eeqj.de/sneak/keyfunc/internal/cli/age"
|
|
"git.eeqj.de/sneak/keyfunc/internal/cli/mnemonic"
|
|
"git.eeqj.de/sneak/keyfunc/internal/cli/options"
|
|
"git.eeqj.de/sneak/keyfunc/internal/cli/ssh"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// Version is what --version prints. The build sets it.
|
|
//
|
|
//nolint:gochecknoglobals // set at build time with -ldflags
|
|
var Version = "dev"
|
|
|
|
// Root returns the whole command tree.
|
|
func Root() *cobra.Command {
|
|
root := &cobra.Command{
|
|
Use: "keyfunc",
|
|
Short: "derive key pairs from a BIP-39 mnemonic",
|
|
Long: "keyfunc turns a BIP-39 mnemonic into key pairs that can " +
|
|
"be recreated from that mnemonic at any time. The same " +
|
|
"mnemonic, key type and index always give the same key.",
|
|
Version: Version,
|
|
SilenceUsage: true,
|
|
SilenceErrors: true,
|
|
}
|
|
|
|
options.Add(root)
|
|
root.AddCommand(ssh.Command(), age.Command(), mnemonic.Command())
|
|
|
|
return root
|
|
}
|
|
|
|
// Main runs the tool and returns the status the process should exit
|
|
// with.
|
|
func Main() int {
|
|
err := Root().Execute()
|
|
if err != nil {
|
|
fmt.Fprintln(os.Stderr, "keyfunc: "+err.Error())
|
|
|
|
return 1
|
|
}
|
|
|
|
return 0
|
|
}
|