From fc41a7a232f4732ceada3d378baff847dd3b2328 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Mon, 27 May 2019 19:39:41 +0200 Subject: [PATCH] core/slip39: use condensed wordlist (cherry picked from commit a3717c7b6c2ab36bcc69b0c504e78644e6a7f0b7) --- core/src/trezor/crypto/slip39.py | 9 +- core/src/trezor/crypto/slip39_wordlist.py | 1027 +-------------------- 2 files changed, 6 insertions(+), 1030 deletions(-) diff --git a/core/src/trezor/crypto/slip39.py b/core/src/trezor/crypto/slip39.py index c09034a495..29cfff9a63 100644 --- a/core/src/trezor/crypto/slip39.py +++ b/core/src/trezor/crypto/slip39.py @@ -85,15 +85,16 @@ DIGEST_INDEX = 254 def word_index(word): + word = word + " " * (8 - len(word)) lo = 0 - hi = len(wordlist) + hi = RADIX while hi - lo > 1: mid = (hi + lo) // 2 - if wordlist[mid] > word: + if wordlist[mid * 8 : mid * 8 + 8] > word: hi = mid else: lo = mid - if not wordlist[lo].startswith(word): + if wordlist[lo * 8 : lo * 8 + 8] != word: raise MnemonicError('Invalid mnemonic word "{}".'.format(word)) return lo @@ -151,7 +152,7 @@ def _int_to_indices(value, length, bits): def mnemonic_from_indices(indices): - return " ".join(wordlist[i] for i in indices) + return " ".join(wordlist[i * 8 : i * 8 + 8].strip() for i in indices) def mnemonic_to_indices(mnemonic): diff --git a/core/src/trezor/crypto/slip39_wordlist.py b/core/src/trezor/crypto/slip39_wordlist.py index 2382137ab0..95815eaefc 100644 --- a/core/src/trezor/crypto/slip39_wordlist.py +++ b/core/src/trezor/crypto/slip39_wordlist.py @@ -1,1026 +1 @@ -wordlist = ( - "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", -) +wordlist = "academicacid acne acquire acrobat activityactress adapt adequateadjust admit adorn adult advance advocateafraid again agency agree aide aircraftairline airport ajar alarm album alcohol alien alive alpha already alto aluminumalways amazing ambitionamount amuse analysisanatomy ancestorancient angel angry animal answer antenna anxiety apart aquatic arcade arena argue armed artist artwork aspect auction august aunt average aviationavoid award away axis axle beam beard beaver become bedroom behaviorbeing believe belong benefit best beyond bike biology birthdaybishop black blanket blessingblimp blind blue body bolt boring born both boundarybraceletbranch brave breathe briefingbroken brother browser bucket budget buildingbulb bulge bumpy bundle burden burning busy buyer cage calcium camera campus canyon capacitycapital capture carbon cards careful cargo carpet carve categorycause ceiling center ceramic championchange charity check chemicalchest 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 criminalcrisis criticalcrowd crucial crunch crush crystal cubic culturalcurious curly custody cylinderdaisy damage dance darknessdatabasedaughterdeadlinedeal debris debut decent decisiondeclare decoratedecreasedeliver demand density deny depart depend depict deploy describedesert desire desktop destroy detaileddetect device devote diagnosedictate diet dilemma diminishdining diploma disasterdiscuss disease dish dismiss display distancedive divorce documentdomain domesticdominantdough downtowndragon dramaticdream dress drift drink drove drug dryer ducklingduke durationdwarf dynamic early earth easel easy echo eclipse ecology edge editor educate either elbow elder electionelegant element elephantelevatorelite else email emerald emissionemperor emphasisemployerempty ending endless endorse enemy energy enforce engage enjoy enlarge entranceenvelopeenvy epidemicepisode equationequip eraser erode escape estate estimateevaluateevening evidenceevil evoke exact example exceed exchangeexclude excuse execute exerciseexhaust exotic expand expect explain express extend extra eyebrow facilityfact failure faint fake false family famous fancy fangs fantasy fatal fatigue favoritefawn fiber fiction filter finance findingsfinger firefly firm fiscal fishing fitness flame flash flavor flea flexibleflip float floral fluff focus forbid force forecastforget formal fortune forward founder fractionfragmentfrequentfreshmanfriar fridge friendlyfrost froth frozen fumes funding furl fused galaxy game garbage garden garlic gasolinegather general genius genre genuine geology gesture glad glance glasses glen glimpse goat golden graduategrant grasp gravity gray greatestgrief 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 hesitatehobo holiday holy home hormone hospitalhour huge human humidityhunting husband hush husky hybrid idea identifyidle image impact imply improve impulse include income increaseindex indicateindustryinfant inform inherit injury inmate insect inside install intend intimateinvasioninvolve iris island isolate item ivory jacket jerky jewelry join judicialjuice jump junctionjunior junk jury justice kernel keyboardkidney kind kitchen knife knit laden ladle ladybug lair lamp languagelarge laser laundry lawsuit leader leaf learn leaves lecture legal legend legs lend length level liberty library license lift likely lilac lily lips liquid listen literaryliving lizard loan lobe locationlosing loud loyalty luck lunar lunch lungs luxury lying lyrics machine magazinemaiden mailman main makeup making mama manager mandate mansion manual marathonmarch market marvel mason materialmath maximum mayor meaning medal medical member memory mental merchantmerit method metric midst mild militarymineral ministermiracle mixed mixture mobile modern modify moisturemoment morning mortgagemother mountainmouse move much mule multiplemuscle museum music mustang nail nationalnecklacenegativenervous network news nuclear numb numerousnylon oasis obesity object observe obtain ocean often olympic omit oral orange orbit order ordinaryorganizeounce oven overall owner paces pacific package paid paintingpajamas pancake pants papa paper parcel parking party patent patrol payment payroll peacefulpeanut peasant pecan penalty pencil percent perfect permit petitionphantom pharmacyphoto phrase physics pickup picture piece pile pink pipelinepistol pitch plains plan plastic platformplayoff pleasureplot plunge practiceprayer preach predatorpregnantpremium prepare presenceprevent priest primary priorityprisonerprivacy prize problem process profile program promise prospectprovide prune public pulse pumps punish puny pupal purchasepurple python quantityquarter quick quiet race racism radar railroadrainbow raisin random ranked rapids raspy reactionrealize rebound rebuild recall receiverrecover regret regular reject relate rememberremind remove render repair repeat replace require rescue researchresidentresponseresult retailerretreat reunion revenue review reward rhyme rhythm rich rival river robin rocky romanticromp roster round royal ruin ruler rumor sack safari salary salon salt satisfy satoshi saver says scandal scared scatter scene scholar science scout scramblescrew script scroll seafood season secret securitysegment senior shadow shaft shame shaped sharp shelter sheriff short should shrimp sidewalksilent silver similar simple single sister skin skunk slap slavery sled slice slim slow slush smart smear smell smirk smith smoking smug snake snapshotsniff society softwaresoldier solutionsoul source space spark speak species spellingspend spew spider spill spine spirit spit spray sprinklesquare squeeze stadium staff standardstartingstation stay steady step stick stilt story strategystrike style subject submit sugar suitablesunlightsuperiorsurface surprisesurvive sweater swimmingswing switch symbolicsympathysyndromesystem tackle tactics tadpole talent task taste taught taxi teacher teammateteaspoontemple tenant tendencytension terminaltestify texture thank that theater theory therapy thorn threatenthumb thunder ticket tidy timber timely ting tofu togethertoleratetotal toxic tracks traffic trainingtransfertrash travelertreat trend trial tricycletrip triumph trouble true trust twice twin type typical ugly ultimateumbrellauncover undergo unfair unfold unhappy union universeunkind unknown unusual unwrap upgrade upstairsusernameusher usual valid valuablevampire vanish various vegan velvet venture verdict verify very veteran vexed victim video view vintage violenceviral visitor visual vitaminsvocal voice volume voter voting walnut warmth warn watch wavy wealthy weapon webcam welcome welfare western width wildlifewindow wine wirelesswisdom withdrawwits wolf woman work worthy wrap wrist writing wrote year yelp yield yoga zero "