| App::FuguSeed::Mnemonic(3p) | Perl Library Manual | App::FuguSeed::Mnemonic(3p) |
NAME
App::FuguSeed::Mnemonic - the 12 seed words of a SeedQR
SYNOPSIS
use App::FuguSeed::Mnemonic;
my @words = split q{ }, $line;
my $fault = App::FuguSeed::Mnemonic->fault(\@words);
die "$fault\n" if defined $fault;
if (App::FuguSeed::Mnemonic->valid(\@words)) {
my $digits = App::FuguSeed::Mnemonic->digits(\@words);
}
else {
my $word = App::FuguSeed::Mnemonic->check_word(\@words);
}
DESCRIPTION
App::FuguSeed::Mnemonic holds the words of one seed. It proves the count and the list membership of 12 words, it proves the BIP39 checksum, it gives the digit string of the SeedQR, and it finds the check word.
Every method is a class method, and every method is pure: it takes values and it returns values. The module touches no stream, so a caller prints the failure message itself. A message names a count or a word position, never a word.
The module runs on core Perl v5.34 with "Digest::SHA" alone, because scripts/pack embeds it in "fuguseed-qr".
fault
fault($words) returns the failure message for the words of the array reference $words, or "undef" when the words pass the check. The input must hold exactly 12 words, and each word must be in the list of App::FuguSeed::List.
digits
digits($words) returns the digit string: the 12 indexes, 0-based, each as 4 decimal digits with leading zeros, in word order. The string holds 48 digits. The caller proves the words with "fault" first.
valid
valid($words) returns true when the last 4 bits of the 12 indexes are the 4 bits that BIP39 requires. The bits are the first bits of the SHA-256 of the 16 entropy bytes.
check_word
check_word($words) returns the one word of the BLUE row of word 12 that makes the checksum valid. The YELLOW block and the BLUE row of the typed word 12 give the 7 entropy bits of that word, and the RED column gives the 4 checksum bits, so the row holds exactly one valid word. The method computes that word, and it runs no trial loop.
RETURN VALUES
fault() returns "undef" for 12 words of the list. digits() returns 48 digits, valid() returns true or false, and check_word() returns one word of the list.
ERRORS
digits(), valid() and check_word() expect 12 words of the list. With another input, the caller gets a warning of Perl and a result without meaning. Call fault() first.
SEE ALSO
App::FuguSeed::List, App::FuguSeed::Codewords, and the BIP39 specification.
AUTHORS
Dick Olsson <hi@senzilla.io>
| 2026-09-23 | OpenBSD |