Skeleton, mnemonic input, derivation, and the ssh pub and priv commands (closes #1)
All checks were successful
check / check (push) Successful in 5s

The module, the script entrypoints and Makefile, Docker-only linting, the mnemonic sources in the specified order with their refusals, the BIP-85 derivation, and keyfunc ssh pub and priv with the README test vectors as tests. Two review rounds; the second passed with no findings.

Model: opus-5 (implementation and review); fable-5-1 (landing)
This commit was merged in pull request #5.
This commit is contained in:
2026-09-07 17:34:54 +02:00
parent c3fd26a1de
commit 279cba6bcf
34 changed files with 1786 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
// Package options holds the flags that every command has and reads
// them back.
package options
import (
"fmt"
"git.eeqj.de/sneak/keyfunc/internal/mnemonic"
"github.com/spf13/cobra"
)
// Add gives a command the flags that every command has. They are
// persistent, so every command below it has them too.
func Add(cmd *cobra.Command) {
cmd.PersistentFlags().String(
"mnemonic-command", "",
"shell command whose output is the mnemonic",
)
cmd.PersistentFlags().Uint32P(
"index", "n", 0,
"which key to derive",
)
}
// Index returns the key index the user asked for.
func Index(cmd *cobra.Command) (uint32, error) {
index, err := cmd.Flags().GetUint32("index")
if err != nil {
return 0, fmt.Errorf("reading the index: %w", err)
}
return index, nil
}
// Mnemonic returns the mnemonic, from the first source that has one.
func Mnemonic(cmd *cobra.Command) (string, error) {
command, err := cmd.Flags().GetString("mnemonic-command")
if err != nil {
return "", fmt.Errorf("reading the mnemonic command: %w", err)
}
return mnemonic.Read(cmd.Context(), command)
}