chore(crypto): refactor slip39 same way as bip39

pull/3011/head
grdddj 1 year ago committed by Martin Milata
parent e7c2800798
commit 8ee4c41938

@ -120,6 +120,7 @@ SOURCE_MOD += [
'vendor/trezor-crypto/sha3.c',
'vendor/trezor-crypto/shamir.c',
'vendor/trezor-crypto/slip39.c',
'vendor/trezor-crypto/slip39_english.c',
]
if EVERYTHING:
SOURCE_MOD += [

@ -116,6 +116,7 @@ SOURCE_MOD += [
'vendor/trezor-crypto/sha3.c',
'vendor/trezor-crypto/shamir.c',
'vendor/trezor-crypto/slip39.c',
'vendor/trezor-crypto/slip39_english.c',
]
if EVERYTHING:
SOURCE_MOD += [

@ -311,6 +311,8 @@ fn generate_trezorhal_bindings() {
// slip39
.allowlist_function("slip39_word_completion_mask")
.allowlist_function("button_sequence_to_word")
.allowlist_var("SLIP39_WORDLIST")
.allowlist_var("SLIP39_WORD_COUNT")
// random
.allowlist_function("random_uniform")
// rgb led

@ -117,6 +117,7 @@ SRCS += shamir.c
SRCS += hmac_drbg.c
SRCS += rfc6979.c
SRCS += slip39.c
SRCS += slip39_english.c
SRCS += zkp_context.c
SRCS += zkp_ecdsa.c
SRCS += zkp_bip340.c

@ -31,11 +31,11 @@
* Returns word at position `index`.
*/
const char* get_word(uint16_t index) {
if (index >= WORDS_COUNT) {
if (index >= SLIP39_WORD_COUNT) {
return NULL;
}
return slip39_wordlist[index];
return SLIP39_WORDLIST[index];
}
/**
@ -44,18 +44,18 @@ const char* get_word(uint16_t index) {
*/
bool word_index(uint16_t* index, const char* word, uint8_t word_length) {
uint16_t lo = 0;
uint16_t hi = WORDS_COUNT;
uint16_t hi = SLIP39_WORD_COUNT;
uint16_t mid = 0;
while ((hi - lo) > 1) {
mid = (hi + lo) / 2;
if (strncmp(slip39_wordlist[mid], word, word_length) > 0) {
if (strncmp(SLIP39_WORDLIST[mid], word, word_length) > 0) {
hi = mid;
} else {
lo = mid;
}
}
if (strncmp(slip39_wordlist[lo], word, word_length) != 0) {
if (strncmp(SLIP39_WORDLIST[lo], word, word_length) != 0) {
return false;
}
*index = lo;
@ -64,7 +64,7 @@ bool word_index(uint16_t* index, const char* word, uint8_t word_length) {
/**
* Returns the index of the first sequence in words_button_seq[] which is not
* less than the given sequence. Returns WORDS_COUNT if there is no such
* less than the given sequence. Returns SLIP39_WORD_COUNT if there is no such
* sequence.
*/
static uint16_t find_sequence(uint16_t sequence) {
@ -73,7 +73,7 @@ static uint16_t find_sequence(uint16_t sequence) {
}
uint16_t lo = 0;
uint16_t hi = WORDS_COUNT;
uint16_t hi = SLIP39_WORD_COUNT;
while (hi - lo > 1) {
uint16_t mid = (hi + lo) / 2;
@ -93,7 +93,7 @@ static uint16_t find_sequence(uint16_t sequence) {
*/
const char* button_sequence_to_word(uint16_t sequence) {
if (sequence == 0) {
return slip39_wordlist[words_button_seq[0].index];
return SLIP39_WORDLIST[words_button_seq[0].index];
}
uint16_t multiplier = 1;
@ -103,12 +103,12 @@ const char* button_sequence_to_word(uint16_t sequence) {
}
uint16_t i = find_sequence(sequence);
if (i >= WORDS_COUNT ||
if (i >= SLIP39_WORD_COUNT ||
words_button_seq[i].sequence - sequence >= multiplier) {
return NULL;
}
return slip39_wordlist[words_button_seq[i].index];
return SLIP39_WORDLIST[words_button_seq[i].index];
}
/**

@ -25,6 +25,8 @@
#ifndef __SLIP39_H__
#define __SLIP39_H__
#define SLIP39_WORD_COUNT 1024
#include <stdbool.h>
#include <stdint.h>
@ -36,4 +38,6 @@ uint16_t slip39_word_completion_mask(uint16_t prefix);
const char* button_sequence_to_word(uint16_t prefix);
extern const char* const SLIP39_WORDLIST[SLIP39_WORD_COUNT];
#endif

@ -0,0 +1,199 @@
/**
* This file is part of the TREZOR project, https://trezor.io/
*
* Copyright (c) SatoshiLabs
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "slip39.h"
const char* const SLIP39_WORDLIST[SLIP39_WORD_COUNT] = {
"academic", "acid", "acne", "acquire", "acrobat", "activity",
"actress", "adapt", "adequate", "adjust", "admit", "adorn",
"adult", "advance", "advocate", "afraid", "again", "agency",
"agree", "aide", "aircraft", "airline", "airport", "ajar",
"alarm", "album", "alcohol", "alien", "alive", "alpha",
"already", "alto", "aluminum", "always", "amazing", "ambition",
"amount", "amuse", "analysis", "anatomy", "ancestor", "ancient",
"angel", "angry", "animal", "answer", "antenna", "anxiety",
"apart", "aquatic", "arcade", "arena", "argue", "armed",
"artist", "artwork", "aspect", "auction", "august", "aunt",
"average", "aviation", "avoid", "award", "away", "axis",
"axle", "beam", "beard", "beaver", "become", "bedroom",
"behavior", "being", "believe", "belong", "benefit", "best",
"beyond", "bike", "biology", "birthday", "bishop", "black",
"blanket", "blessing", "blimp", "blind", "blue", "body",
"bolt", "boring", "born", "both", "boundary", "bracelet",
"branch", "brave", "breathe", "briefing", "broken", "brother",
"browser", "bucket", "budget", "building", "bulb", "bulge",
"bumpy", "bundle", "burden", "burning", "busy", "buyer",
"cage", "calcium", "camera", "campus", "canyon", "capacity",
"capital", "capture", "carbon", "cards", "careful", "cargo",
"carpet", "carve", "category", "cause", "ceiling", "center",
"ceramic", "champion", "change", "charity", "check", "chemical",
"chest", "chew", "chubby", "cinema", "civil", "class",
"clay", "cleanup", "client", "climate", "clinic", "clock",
"clogs", "closet", "clothes", "club", "cluster", "coal",
"coastal", "coding", "column", "company", "corner", "costume",
"counter", "course", "cover", "cowboy", "cradle", "craft",
"crazy", "credit", "cricket", "criminal", "crisis", "critical",
"crowd", "crucial", "crunch", "crush", "crystal", "cubic",
"cultural", "curious", "curly", "custody", "cylinder", "daisy",
"damage", "dance", "darkness", "database", "daughter", "deadline",
"deal", "debris", "debut", "decent", "decision", "declare",
"decorate", "decrease", "deliver", "demand", "density", "deny",
"depart", "depend", "depict", "deploy", "describe", "desert",
"desire", "desktop", "destroy", "detailed", "detect", "device",
"devote", "diagnose", "dictate", "diet", "dilemma", "diminish",
"dining", "diploma", "disaster", "discuss", "disease", "dish",
"dismiss", "display", "distance", "dive", "divorce", "document",
"domain", "domestic", "dominant", "dough", "downtown", "dragon",
"dramatic", "dream", "dress", "drift", "drink", "drove",
"drug", "dryer", "duckling", "duke", "duration", "dwarf",
"dynamic", "early", "earth", "easel", "easy", "echo",
"eclipse", "ecology", "edge", "editor", "educate", "either",
"elbow", "elder", "election", "elegant", "element", "elephant",
"elevator", "elite", "else", "email", "emerald", "emission",
"emperor", "emphasis", "employer", "empty", "ending", "endless",
"endorse", "enemy", "energy", "enforce", "engage", "enjoy",
"enlarge", "entrance", "envelope", "envy", "epidemic", "episode",
"equation", "equip", "eraser", "erode", "escape", "estate",
"estimate", "evaluate", "evening", "evidence", "evil", "evoke",
"exact", "example", "exceed", "exchange", "exclude", "excuse",
"execute", "exercise", "exhaust", "exotic", "expand", "expect",
"explain", "express", "extend", "extra", "eyebrow", "facility",
"fact", "failure", "faint", "fake", "false", "family",
"famous", "fancy", "fangs", "fantasy", "fatal", "fatigue",
"favorite", "fawn", "fiber", "fiction", "filter", "finance",
"findings", "finger", "firefly", "firm", "fiscal", "fishing",
"fitness", "flame", "flash", "flavor", "flea", "flexible",
"flip", "float", "floral", "fluff", "focus", "forbid",
"force", "forecast", "forget", "formal", "fortune", "forward",
"founder", "fraction", "fragment", "frequent", "freshman", "friar",
"fridge", "friendly", "frost", "froth", "frozen", "fumes",
"funding", "furl", "fused", "galaxy", "game", "garbage",
"garden", "garlic", "gasoline", "gather", "general", "genius",
"genre", "genuine", "geology", "gesture", "glad", "glance",
"glasses", "glen", "glimpse", "goat", "golden", "graduate",
"grant", "grasp", "gravity", "gray", "greatest", "grief",
"grill", "grin", "grocery", "gross", "group", "grownup",
"grumpy", "guard", "guest", "guilt", "guitar", "gums",
"hairy", "hamster", "hand", "hanger", "harvest", "have",
"havoc", "hawk", "hazard", "headset", "health", "hearing",
"heat", "helpful", "herald", "herd", "hesitate", "hobo",
"holiday", "holy", "home", "hormone", "hospital", "hour",
"huge", "human", "humidity", "hunting", "husband", "hush",
"husky", "hybrid", "idea", "identify", "idle", "image",
"impact", "imply", "improve", "impulse", "include", "income",
"increase", "index", "indicate", "industry", "infant", "inform",
"inherit", "injury", "inmate", "insect", "inside", "install",
"intend", "intimate", "invasion", "involve", "iris", "island",
"isolate", "item", "ivory", "jacket", "jerky", "jewelry",
"join", "judicial", "juice", "jump", "junction", "junior",
"junk", "jury", "justice", "kernel", "keyboard", "kidney",
"kind", "kitchen", "knife", "knit", "laden", "ladle",
"ladybug", "lair", "lamp", "language", "large", "laser",
"laundry", "lawsuit", "leader", "leaf", "learn", "leaves",
"lecture", "legal", "legend", "legs", "lend", "length",
"level", "liberty", "library", "license", "lift", "likely",
"lilac", "lily", "lips", "liquid", "listen", "literary",
"living", "lizard", "loan", "lobe", "location", "losing",
"loud", "loyalty", "luck", "lunar", "lunch", "lungs",
"luxury", "lying", "lyrics", "machine", "magazine", "maiden",
"mailman", "main", "makeup", "making", "mama", "manager",
"mandate", "mansion", "manual", "marathon", "march", "market",
"marvel", "mason", "material", "math", "maximum", "mayor",
"meaning", "medal", "medical", "member", "memory", "mental",
"merchant", "merit", "method", "metric", "midst", "mild",
"military", "mineral", "minister", "miracle", "mixed", "mixture",
"mobile", "modern", "modify", "moisture", "moment", "morning",
"mortgage", "mother", "mountain", "mouse", "move", "much",
"mule", "multiple", "muscle", "museum", "music", "mustang",
"nail", "national", "necklace", "negative", "nervous", "network",
"news", "nuclear", "numb", "numerous", "nylon", "oasis",
"obesity", "object", "observe", "obtain", "ocean", "often",
"olympic", "omit", "oral", "orange", "orbit", "order",
"ordinary", "organize", "ounce", "oven", "overall", "owner",
"paces", "pacific", "package", "paid", "painting", "pajamas",
"pancake", "pants", "papa", "paper", "parcel", "parking",
"party", "patent", "patrol", "payment", "payroll", "peaceful",
"peanut", "peasant", "pecan", "penalty", "pencil", "percent",
"perfect", "permit", "petition", "phantom", "pharmacy", "photo",
"phrase", "physics", "pickup", "picture", "piece", "pile",
"pink", "pipeline", "pistol", "pitch", "plains", "plan",
"plastic", "platform", "playoff", "pleasure", "plot", "plunge",
"practice", "prayer", "preach", "predator", "pregnant", "premium",
"prepare", "presence", "prevent", "priest", "primary", "priority",
"prisoner", "privacy", "prize", "problem", "process", "profile",
"program", "promise", "prospect", "provide", "prune", "public",
"pulse", "pumps", "punish", "puny", "pupal", "purchase",
"purple", "python", "quantity", "quarter", "quick", "quiet",
"race", "racism", "radar", "railroad", "rainbow", "raisin",
"random", "ranked", "rapids", "raspy", "reaction", "realize",
"rebound", "rebuild", "recall", "receiver", "recover", "regret",
"regular", "reject", "relate", "remember", "remind", "remove",
"render", "repair", "repeat", "replace", "require", "rescue",
"research", "resident", "response", "result", "retailer", "retreat",
"reunion", "revenue", "review", "reward", "rhyme", "rhythm",
"rich", "rival", "river", "robin", "rocky", "romantic",
"romp", "roster", "round", "royal", "ruin", "ruler",
"rumor", "sack", "safari", "salary", "salon", "salt",
"satisfy", "satoshi", "saver", "says", "scandal", "scared",
"scatter", "scene", "scholar", "science", "scout", "scramble",
"screw", "script", "scroll", "seafood", "season", "secret",
"security", "segment", "senior", "shadow", "shaft", "shame",
"shaped", "sharp", "shelter", "sheriff", "short", "should",
"shrimp", "sidewalk", "silent", "silver", "similar", "simple",
"single", "sister", "skin", "skunk", "slap", "slavery",
"sled", "slice", "slim", "slow", "slush", "smart",
"smear", "smell", "smirk", "smith", "smoking", "smug",
"snake", "snapshot", "sniff", "society", "software", "soldier",
"solution", "soul", "source", "space", "spark", "speak",
"species", "spelling", "spend", "spew", "spider", "spill",
"spine", "spirit", "spit", "spray", "sprinkle", "square",
"squeeze", "stadium", "staff", "standard", "starting", "station",
"stay", "steady", "step", "stick", "stilt", "story",
"strategy", "strike", "style", "subject", "submit", "sugar",
"suitable", "sunlight", "superior", "surface", "surprise", "survive",
"sweater", "swimming", "swing", "switch", "symbolic", "sympathy",
"syndrome", "system", "tackle", "tactics", "tadpole", "talent",
"task", "taste", "taught", "taxi", "teacher", "teammate",
"teaspoon", "temple", "tenant", "tendency", "tension", "terminal",
"testify", "texture", "thank", "that", "theater", "theory",
"therapy", "thorn", "threaten", "thumb", "thunder", "ticket",
"tidy", "timber", "timely", "ting", "tofu", "together",
"tolerate", "total", "toxic", "tracks", "traffic", "training",
"transfer", "trash", "traveler", "treat", "trend", "trial",
"tricycle", "trip", "triumph", "trouble", "true", "trust",
"twice", "twin", "type", "typical", "ugly", "ultimate",
"umbrella", "uncover", "undergo", "unfair", "unfold", "unhappy",
"union", "universe", "unkind", "unknown", "unusual", "unwrap",
"upgrade", "upstairs", "username", "usher", "usual", "valid",
"valuable", "vampire", "vanish", "various", "vegan", "velvet",
"venture", "verdict", "verify", "very", "veteran", "vexed",
"victim", "video", "view", "vintage", "violence", "viral",
"visitor", "visual", "vitamins", "vocal", "voice", "volume",
"voter", "voting", "walnut", "warmth", "warn", "watch",
"wavy", "wealthy", "weapon", "webcam", "welcome", "welfare",
"western", "width", "wildlife", "window", "wine", "wireless",
"wisdom", "withdraw", "wits", "wolf", "woman", "work",
"worthy", "wrap", "wrist", "writing", "wrote", "year",
"yelp", "yield", "yoga", "zero",
};

@ -26,182 +26,7 @@
#define __SLIP39_WORDLIST_H__
#include <stdint.h>
#define WORDS_COUNT 1024
static const char* const slip39_wordlist[WORDS_COUNT] = {
"academic", "acid", "acne", "acquire", "acrobat", "activity",
"actress", "adapt", "adequate", "adjust", "admit", "adorn",
"adult", "advance", "advocate", "afraid", "again", "agency",
"agree", "aide", "aircraft", "airline", "airport", "ajar",
"alarm", "album", "alcohol", "alien", "alive", "alpha",
"already", "alto", "aluminum", "always", "amazing", "ambition",
"amount", "amuse", "analysis", "anatomy", "ancestor", "ancient",
"angel", "angry", "animal", "answer", "antenna", "anxiety",
"apart", "aquatic", "arcade", "arena", "argue", "armed",
"artist", "artwork", "aspect", "auction", "august", "aunt",
"average", "aviation", "avoid", "award", "away", "axis",
"axle", "beam", "beard", "beaver", "become", "bedroom",
"behavior", "being", "believe", "belong", "benefit", "best",
"beyond", "bike", "biology", "birthday", "bishop", "black",
"blanket", "blessing", "blimp", "blind", "blue", "body",
"bolt", "boring", "born", "both", "boundary", "bracelet",
"branch", "brave", "breathe", "briefing", "broken", "brother",
"browser", "bucket", "budget", "building", "bulb", "bulge",
"bumpy", "bundle", "burden", "burning", "busy", "buyer",
"cage", "calcium", "camera", "campus", "canyon", "capacity",
"capital", "capture", "carbon", "cards", "careful", "cargo",
"carpet", "carve", "category", "cause", "ceiling", "center",
"ceramic", "champion", "change", "charity", "check", "chemical",
"chest", "chew", "chubby", "cinema", "civil", "class",
"clay", "cleanup", "client", "climate", "clinic", "clock",
"clogs", "closet", "clothes", "club", "cluster", "coal",
"coastal", "coding", "column", "company", "corner", "costume",
"counter", "course", "cover", "cowboy", "cradle", "craft",
"crazy", "credit", "cricket", "criminal", "crisis", "critical",
"crowd", "crucial", "crunch", "crush", "crystal", "cubic",
"cultural", "curious", "curly", "custody", "cylinder", "daisy",
"damage", "dance", "darkness", "database", "daughter", "deadline",
"deal", "debris", "debut", "decent", "decision", "declare",
"decorate", "decrease", "deliver", "demand", "density", "deny",
"depart", "depend", "depict", "deploy", "describe", "desert",
"desire", "desktop", "destroy", "detailed", "detect", "device",
"devote", "diagnose", "dictate", "diet", "dilemma", "diminish",
"dining", "diploma", "disaster", "discuss", "disease", "dish",
"dismiss", "display", "distance", "dive", "divorce", "document",
"domain", "domestic", "dominant", "dough", "downtown", "dragon",
"dramatic", "dream", "dress", "drift", "drink", "drove",
"drug", "dryer", "duckling", "duke", "duration", "dwarf",
"dynamic", "early", "earth", "easel", "easy", "echo",
"eclipse", "ecology", "edge", "editor", "educate", "either",
"elbow", "elder", "election", "elegant", "element", "elephant",
"elevator", "elite", "else", "email", "emerald", "emission",
"emperor", "emphasis", "employer", "empty", "ending", "endless",
"endorse", "enemy", "energy", "enforce", "engage", "enjoy",
"enlarge", "entrance", "envelope", "envy", "epidemic", "episode",
"equation", "equip", "eraser", "erode", "escape", "estate",
"estimate", "evaluate", "evening", "evidence", "evil", "evoke",
"exact", "example", "exceed", "exchange", "exclude", "excuse",
"execute", "exercise", "exhaust", "exotic", "expand", "expect",
"explain", "express", "extend", "extra", "eyebrow", "facility",
"fact", "failure", "faint", "fake", "false", "family",
"famous", "fancy", "fangs", "fantasy", "fatal", "fatigue",
"favorite", "fawn", "fiber", "fiction", "filter", "finance",
"findings", "finger", "firefly", "firm", "fiscal", "fishing",
"fitness", "flame", "flash", "flavor", "flea", "flexible",
"flip", "float", "floral", "fluff", "focus", "forbid",
"force", "forecast", "forget", "formal", "fortune", "forward",
"founder", "fraction", "fragment", "frequent", "freshman", "friar",
"fridge", "friendly", "frost", "froth", "frozen", "fumes",
"funding", "furl", "fused", "galaxy", "game", "garbage",
"garden", "garlic", "gasoline", "gather", "general", "genius",
"genre", "genuine", "geology", "gesture", "glad", "glance",
"glasses", "glen", "glimpse", "goat", "golden", "graduate",
"grant", "grasp", "gravity", "gray", "greatest", "grief",
"grill", "grin", "grocery", "gross", "group", "grownup",
"grumpy", "guard", "guest", "guilt", "guitar", "gums",
"hairy", "hamster", "hand", "hanger", "harvest", "have",
"havoc", "hawk", "hazard", "headset", "health", "hearing",
"heat", "helpful", "herald", "herd", "hesitate", "hobo",
"holiday", "holy", "home", "hormone", "hospital", "hour",
"huge", "human", "humidity", "hunting", "husband", "hush",
"husky", "hybrid", "idea", "identify", "idle", "image",
"impact", "imply", "improve", "impulse", "include", "income",
"increase", "index", "indicate", "industry", "infant", "inform",
"inherit", "injury", "inmate", "insect", "inside", "install",
"intend", "intimate", "invasion", "involve", "iris", "island",
"isolate", "item", "ivory", "jacket", "jerky", "jewelry",
"join", "judicial", "juice", "jump", "junction", "junior",
"junk", "jury", "justice", "kernel", "keyboard", "kidney",
"kind", "kitchen", "knife", "knit", "laden", "ladle",
"ladybug", "lair", "lamp", "language", "large", "laser",
"laundry", "lawsuit", "leader", "leaf", "learn", "leaves",
"lecture", "legal", "legend", "legs", "lend", "length",
"level", "liberty", "library", "license", "lift", "likely",
"lilac", "lily", "lips", "liquid", "listen", "literary",
"living", "lizard", "loan", "lobe", "location", "losing",
"loud", "loyalty", "luck", "lunar", "lunch", "lungs",
"luxury", "lying", "lyrics", "machine", "magazine", "maiden",
"mailman", "main", "makeup", "making", "mama", "manager",
"mandate", "mansion", "manual", "marathon", "march", "market",
"marvel", "mason", "material", "math", "maximum", "mayor",
"meaning", "medal", "medical", "member", "memory", "mental",
"merchant", "merit", "method", "metric", "midst", "mild",
"military", "mineral", "minister", "miracle", "mixed", "mixture",
"mobile", "modern", "modify", "moisture", "moment", "morning",
"mortgage", "mother", "mountain", "mouse", "move", "much",
"mule", "multiple", "muscle", "museum", "music", "mustang",
"nail", "national", "necklace", "negative", "nervous", "network",
"news", "nuclear", "numb", "numerous", "nylon", "oasis",
"obesity", "object", "observe", "obtain", "ocean", "often",
"olympic", "omit", "oral", "orange", "orbit", "order",
"ordinary", "organize", "ounce", "oven", "overall", "owner",
"paces", "pacific", "package", "paid", "painting", "pajamas",
"pancake", "pants", "papa", "paper", "parcel", "parking",
"party", "patent", "patrol", "payment", "payroll", "peaceful",
"peanut", "peasant", "pecan", "penalty", "pencil", "percent",
"perfect", "permit", "petition", "phantom", "pharmacy", "photo",
"phrase", "physics", "pickup", "picture", "piece", "pile",
"pink", "pipeline", "pistol", "pitch", "plains", "plan",
"plastic", "platform", "playoff", "pleasure", "plot", "plunge",
"practice", "prayer", "preach", "predator", "pregnant", "premium",
"prepare", "presence", "prevent", "priest", "primary", "priority",
"prisoner", "privacy", "prize", "problem", "process", "profile",
"program", "promise", "prospect", "provide", "prune", "public",
"pulse", "pumps", "punish", "puny", "pupal", "purchase",
"purple", "python", "quantity", "quarter", "quick", "quiet",
"race", "racism", "radar", "railroad", "rainbow", "raisin",
"random", "ranked", "rapids", "raspy", "reaction", "realize",
"rebound", "rebuild", "recall", "receiver", "recover", "regret",
"regular", "reject", "relate", "remember", "remind", "remove",
"render", "repair", "repeat", "replace", "require", "rescue",
"research", "resident", "response", "result", "retailer", "retreat",
"reunion", "revenue", "review", "reward", "rhyme", "rhythm",
"rich", "rival", "river", "robin", "rocky", "romantic",
"romp", "roster", "round", "royal", "ruin", "ruler",
"rumor", "sack", "safari", "salary", "salon", "salt",
"satisfy", "satoshi", "saver", "says", "scandal", "scared",
"scatter", "scene", "scholar", "science", "scout", "scramble",
"screw", "script", "scroll", "seafood", "season", "secret",
"security", "segment", "senior", "shadow", "shaft", "shame",
"shaped", "sharp", "shelter", "sheriff", "short", "should",
"shrimp", "sidewalk", "silent", "silver", "similar", "simple",
"single", "sister", "skin", "skunk", "slap", "slavery",
"sled", "slice", "slim", "slow", "slush", "smart",
"smear", "smell", "smirk", "smith", "smoking", "smug",
"snake", "snapshot", "sniff", "society", "software", "soldier",
"solution", "soul", "source", "space", "spark", "speak",
"species", "spelling", "spend", "spew", "spider", "spill",
"spine", "spirit", "spit", "spray", "sprinkle", "square",
"squeeze", "stadium", "staff", "standard", "starting", "station",
"stay", "steady", "step", "stick", "stilt", "story",
"strategy", "strike", "style", "subject", "submit", "sugar",
"suitable", "sunlight", "superior", "surface", "surprise", "survive",
"sweater", "swimming", "swing", "switch", "symbolic", "sympathy",
"syndrome", "system", "tackle", "tactics", "tadpole", "talent",
"task", "taste", "taught", "taxi", "teacher", "teammate",
"teaspoon", "temple", "tenant", "tendency", "tension", "terminal",
"testify", "texture", "thank", "that", "theater", "theory",
"therapy", "thorn", "threaten", "thumb", "thunder", "ticket",
"tidy", "timber", "timely", "ting", "tofu", "together",
"tolerate", "total", "toxic", "tracks", "traffic", "training",
"transfer", "trash", "traveler", "treat", "trend", "trial",
"tricycle", "trip", "triumph", "trouble", "true", "trust",
"twice", "twin", "type", "typical", "ugly", "ultimate",
"umbrella", "uncover", "undergo", "unfair", "unfold", "unhappy",
"union", "universe", "unkind", "unknown", "unusual", "unwrap",
"upgrade", "upstairs", "username", "usher", "usual", "valid",
"valuable", "vampire", "vanish", "various", "vegan", "velvet",
"venture", "verdict", "verify", "very", "veteran", "vexed",
"victim", "video", "view", "vintage", "violence", "viral",
"visitor", "visual", "vitamins", "vocal", "voice", "volume",
"voter", "voting", "walnut", "warmth", "warn", "watch",
"wavy", "wealthy", "weapon", "webcam", "welcome", "welfare",
"western", "width", "wildlife", "window", "wine", "wireless",
"wisdom", "withdraw", "wits", "wolf", "woman", "work",
"worthy", "wrap", "wrist", "writing", "wrote", "year",
"yelp", "yield", "yoga", "zero",
};
#include "slip39.h"
/**
* This array contains number representations of SLIP-39 words.
@ -216,7 +41,7 @@ static const char* const slip39_wordlist[WORDS_COUNT] = {
static const struct {
uint16_t sequence;
uint16_t index;
} words_button_seq[WORDS_COUNT] = {
} words_button_seq[SLIP39_WORD_COUNT] = {
{1212, 0}, // academic
{1216, 7}, // adapt
{1236, 8}, // adequate

@ -5727,8 +5727,8 @@ END_TEST
START_TEST(test_slip39_word_completion) {
const char t9[] = {1, 1, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5,
6, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 9, 9};
for (size_t i = 0; i < WORDS_COUNT; ++i) {
const char *word = slip39_wordlist[i];
for (size_t i = 0; i < SLIP39_WORD_COUNT; ++i) {
const char *word = SLIP39_WORDLIST[i];
uint16_t prefix = t9[word[0] - 'a'];
for (size_t j = 1; j < 4; ++j) {
uint16_t mask = slip39_word_completion_mask(prefix);

Loading…
Cancel
Save