check / check (push) Successful in 4m30s
go-bip39's repository no longer exists, so keyfunc now carries the part of v1.1.0 it uses, with the upstream LICENSE beside it, and imports it from internal/bip39. Upstream's tests and test vectors for the kept code come along unchanged; where they called a removed function, crypto/rand stands in for NewEntropy and EntropyFromMnemonic for MnemonicToByteArray. Changes beyond the trimming are what the linter asked for: the package-level variables moved into the functions that use them, three error strings were lower-cased, and the unknown-word error now wraps ErrInvalidMnemonic. go.mod no longer requires go-bip39. go mod tidy keeps its two go.sum lines, because a test in sneak/secret's bip85 package imports it, and drops six lines that only go-bip39's own requirements needed. Model: opus-5-5 Co-authored-by: clawbot <sneak+clawbot@sneak.cloud>
31 lines
1.2 KiB
Go
31 lines
1.2 KiB
Go
package bip39_test
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"fmt"
|
|
|
|
"sneak.berlin/go/keyfunc/internal/bip39"
|
|
)
|
|
|
|
//nolint:lll // the test vector and its output, kept as upstream wrote them
|
|
func ExampleNewMnemonic() {
|
|
// the entropy can be any byte slice, generated how pleased,
|
|
// as long its bit size is a multiple of 32 and is within
|
|
// the inclusive range of {128,256}
|
|
entropy, _ := hex.DecodeString("066dca1a2bb7e8a1db2832148ce9933eea0f3ac9548d793112d9a95c9407efad")
|
|
|
|
// generate a mnemomic
|
|
mnemomic, _ := bip39.NewMnemonic(entropy)
|
|
fmt.Println(mnemomic)
|
|
// output:
|
|
// all hour make first leader extend hole alien behind guard gospel lava path output census museum junior mass reopen famous sing advance salt reform
|
|
}
|
|
|
|
//nolint:lll // the test vector and its output, kept as upstream wrote them
|
|
func ExampleNewSeed() {
|
|
seed := bip39.NewSeed("all hour make first leader extend hole alien behind guard gospel lava path output census museum junior mass reopen famous sing advance salt reform", "TREZOR")
|
|
fmt.Println(hex.EncodeToString(seed))
|
|
// output:
|
|
// 26e975ec644423f4a4c4f4215ef09b4bd7ef924e85d1d17c4cf3f136c2863cf6df0a475045652c57eb5fb41513ca2a2d67722b77e954b4b3fc11f7590449191d
|
|
}
|