Files
keyfunc/internal/derive/derive_test.go
sneak 90a7c96cd1
All checks were successful
check / check (push) Successful in 34s
Skeleton, mnemonic input, derivation, and the ssh commands (closes #1)
The tool derives ed25519 SSH keys from a BIP-39 mnemonic and prints
them, either as an authorized_keys line or as an unencrypted OpenSSH
private key. Both README test vectors are asserted in the tests.

The mnemonic is looked for in the order the README gives, and refused
when it fails its checksum or when there is nowhere left to look.

The repository standards come with it: the vendored linter
configuration and policies, the script/ entrypoints with a thin
Makefile, and a Gitea workflow. Linting happens only inside the image
built from Dockerfile.lint, which pins the linter by hash, so the root
Dockerfile runs the formatting check, the tests and the build, and
script/cibuild runs the linter before it.

Model: opus-5
2026-09-07 14:44:45 +00:00

52 lines
1.2 KiB
Go

package derive_test
import (
"bytes"
"strings"
"testing"
"git.eeqj.de/sneak/keyfunc/internal/derive"
"github.com/stretchr/testify/require"
)
// application is the number the SSH key type uses.
const application = 838372
// example returns the mnemonic every BIP-39 document uses to show its
// test vectors: eleven abandons and about.
func example() string {
return strings.Repeat("abandon ", 11) + "about"
}
func TestPathIsTheOneTheSpecificationGives(t *testing.T) {
t.Parallel()
require.Equal(t, "m/83696968'/838372'/3'", derive.Path(application, 3))
}
func TestEveryIndexGivesItsOwnBytes(t *testing.T) {
t.Parallel()
first, err := derive.Bytes(example(), application, 0)
require.NoError(t, err)
require.Len(t, first, derive.Size)
second, err := derive.Bytes(example(), application, 1)
require.NoError(t, err)
require.Len(t, second, derive.Size)
require.False(t, bytes.Equal(first, second))
}
func TestTheSameInputAlwaysGivesTheSameBytes(t *testing.T) {
t.Parallel()
once, err := derive.Bytes(example(), application, 7)
require.NoError(t, err)
again, err := derive.Bytes(example(), application, 7)
require.NoError(t, err)
require.Equal(t, once, again)
}