Socket
Socket
Sign inDemoInstall

@cosmjs/crypto

Package Overview
Dependencies
Maintainers
2
Versions
107
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cosmjs/crypto - npm Package Compare versions

Comparing version 0.26.6 to 0.26.8

build/pbkdf2.d.ts

10

build/bip39.d.ts

@@ -1,2 +0,10 @@

import { EnglishMnemonic } from "./englishmnemonic";
export declare function entropyToMnemonic(entropy: Uint8Array): string;
export declare function mnemonicToEntropy(mnemonic: string): Uint8Array;
export declare class EnglishMnemonic {
static readonly wordlist: readonly string[];
private static readonly mnemonicMatcher;
private readonly data;
constructor(mnemonic: string);
toString(): string;
}
export declare class Bip39 {

@@ -3,0 +11,0 @@ /**

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Bip39 = void 0;
exports.Bip39 = exports.EnglishMnemonic = exports.mnemonicToEntropy = exports.entropyToMnemonic = void 0;
const encoding_1 = require("@cosmjs/encoding");
const bip39 = __importStar(require("bip39"));
const englishmnemonic_1 = require("./englishmnemonic");
const pbkdf2_1 = require("./pbkdf2");
const sha_1 = require("./sha");
const wordlist = [
"abandon",
"ability",
"able",
"about",
"above",
"absent",
"absorb",
"abstract",
"absurd",
"abuse",
"access",
"accident",
"account",
"accuse",
"achieve",
"acid",
"acoustic",
"acquire",
"across",
"act",
"action",
"actor",
"actress",
"actual",
"adapt",
"add",
"addict",
"address",
"adjust",
"admit",
"adult",
"advance",
"advice",
"aerobic",
"affair",
"afford",
"afraid",
"again",
"age",
"agent",
"agree",
"ahead",
"aim",
"air",
"airport",
"aisle",
"alarm",
"album",
"alcohol",
"alert",
"alien",
"all",
"alley",
"allow",
"almost",
"alone",
"alpha",
"already",
"also",
"alter",
"always",
"amateur",
"amazing",
"among",
"amount",
"amused",
"analyst",
"anchor",
"ancient",
"anger",
"angle",
"angry",
"animal",
"ankle",
"announce",
"annual",
"another",
"answer",
"antenna",
"antique",
"anxiety",
"any",
"apart",
"apology",
"appear",
"apple",
"approve",
"april",
"arch",
"arctic",
"area",
"arena",
"argue",
"arm",
"armed",
"armor",
"army",
"around",
"arrange",
"arrest",
"arrive",
"arrow",
"art",
"artefact",
"artist",
"artwork",
"ask",
"aspect",
"assault",
"asset",
"assist",
"assume",
"asthma",
"athlete",
"atom",
"attack",
"attend",
"attitude",
"attract",
"auction",
"audit",
"august",
"aunt",
"author",
"auto",
"autumn",
"average",
"avocado",
"avoid",
"awake",
"aware",
"away",
"awesome",
"awful",
"awkward",
"axis",
"baby",
"bachelor",
"bacon",
"badge",
"bag",
"balance",
"balcony",
"ball",
"bamboo",
"banana",
"banner",
"bar",
"barely",
"bargain",
"barrel",
"base",
"basic",
"basket",
"battle",
"beach",
"bean",
"beauty",
"because",
"become",
"beef",
"before",
"begin",
"behave",
"behind",
"believe",
"below",
"belt",
"bench",
"benefit",
"best",
"betray",
"better",
"between",
"beyond",
"bicycle",
"bid",
"bike",
"bind",
"biology",
"bird",
"birth",
"bitter",
"black",
"blade",
"blame",
"blanket",
"blast",
"bleak",
"bless",
"blind",
"blood",
"blossom",
"blouse",
"blue",
"blur",
"blush",
"board",
"boat",
"body",
"boil",
"bomb",
"bone",
"bonus",
"book",
"boost",
"border",
"boring",
"borrow",
"boss",
"bottom",
"bounce",
"box",
"boy",
"bracket",
"brain",
"brand",
"brass",
"brave",
"bread",
"breeze",
"brick",
"bridge",
"brief",
"bright",
"bring",
"brisk",
"broccoli",
"broken",
"bronze",
"broom",
"brother",
"brown",
"brush",
"bubble",
"buddy",
"budget",
"buffalo",
"build",
"bulb",
"bulk",
"bullet",
"bundle",
"bunker",
"burden",
"burger",
"burst",
"bus",
"business",
"busy",
"butter",
"buyer",
"buzz",
"cabbage",
"cabin",
"cable",
"cactus",
"cage",
"cake",
"call",
"calm",
"camera",
"camp",
"can",
"canal",
"cancel",
"candy",
"cannon",
"canoe",
"canvas",
"canyon",
"capable",
"capital",
"captain",
"car",
"carbon",
"card",
"cargo",
"carpet",
"carry",
"cart",
"case",
"cash",
"casino",
"castle",
"casual",
"cat",
"catalog",
"catch",
"category",
"cattle",
"caught",
"cause",
"caution",
"cave",
"ceiling",
"celery",
"cement",
"census",
"century",
"cereal",
"certain",
"chair",
"chalk",
"champion",
"change",
"chaos",
"chapter",
"charge",
"chase",
"chat",
"cheap",
"check",
"cheese",
"chef",
"cherry",
"chest",
"chicken",
"chief",
"child",
"chimney",
"choice",
"choose",
"chronic",
"chuckle",
"chunk",
"churn",
"cigar",
"cinnamon",
"circle",
"citizen",
"city",
"civil",
"claim",
"clap",
"clarify",
"claw",
"clay",
"clean",
"clerk",
"clever",
"click",
"client",
"cliff",
"climb",
"clinic",
"clip",
"clock",
"clog",
"close",
"cloth",
"cloud",
"clown",
"club",
"clump",
"cluster",
"clutch",
"coach",
"coast",
"coconut",
"code",
"coffee",
"coil",
"coin",
"collect",
"color",
"column",
"combine",
"come",
"comfort",
"comic",
"common",
"company",
"concert",
"conduct",
"confirm",
"congress",
"connect",
"consider",
"control",
"convince",
"cook",
"cool",
"copper",
"copy",
"coral",
"core",
"corn",
"correct",
"cost",
"cotton",
"couch",
"country",
"couple",
"course",
"cousin",
"cover",
"coyote",
"crack",
"cradle",
"craft",
"cram",
"crane",
"crash",
"crater",
"crawl",
"crazy",
"cream",
"credit",
"creek",
"crew",
"cricket",
"crime",
"crisp",
"critic",
"crop",
"cross",
"crouch",
"crowd",
"crucial",
"cruel",
"cruise",
"crumble",
"crunch",
"crush",
"cry",
"crystal",
"cube",
"culture",
"cup",
"cupboard",
"curious",
"current",
"curtain",
"curve",
"cushion",
"custom",
"cute",
"cycle",
"dad",
"damage",
"damp",
"dance",
"danger",
"daring",
"dash",
"daughter",
"dawn",
"day",
"deal",
"debate",
"debris",
"decade",
"december",
"decide",
"decline",
"decorate",
"decrease",
"deer",
"defense",
"define",
"defy",
"degree",
"delay",
"deliver",
"demand",
"demise",
"denial",
"dentist",
"deny",
"depart",
"depend",
"deposit",
"depth",
"deputy",
"derive",
"describe",
"desert",
"design",
"desk",
"despair",
"destroy",
"detail",
"detect",
"develop",
"device",
"devote",
"diagram",
"dial",
"diamond",
"diary",
"dice",
"diesel",
"diet",
"differ",
"digital",
"dignity",
"dilemma",
"dinner",
"dinosaur",
"direct",
"dirt",
"disagree",
"discover",
"disease",
"dish",
"dismiss",
"disorder",
"display",
"distance",
"divert",
"divide",
"divorce",
"dizzy",
"doctor",
"document",
"dog",
"doll",
"dolphin",
"domain",
"donate",
"donkey",
"donor",
"door",
"dose",
"double",
"dove",
"draft",
"dragon",
"drama",
"drastic",
"draw",
"dream",
"dress",
"drift",
"drill",
"drink",
"drip",
"drive",
"drop",
"drum",
"dry",
"duck",
"dumb",
"dune",
"during",
"dust",
"dutch",
"duty",
"dwarf",
"dynamic",
"eager",
"eagle",
"early",
"earn",
"earth",
"easily",
"east",
"easy",
"echo",
"ecology",
"economy",
"edge",
"edit",
"educate",
"effort",
"egg",
"eight",
"either",
"elbow",
"elder",
"electric",
"elegant",
"element",
"elephant",
"elevator",
"elite",
"else",
"embark",
"embody",
"embrace",
"emerge",
"emotion",
"employ",
"empower",
"empty",
"enable",
"enact",
"end",
"endless",
"endorse",
"enemy",
"energy",
"enforce",
"engage",
"engine",
"enhance",
"enjoy",
"enlist",
"enough",
"enrich",
"enroll",
"ensure",
"enter",
"entire",
"entry",
"envelope",
"episode",
"equal",
"equip",
"era",
"erase",
"erode",
"erosion",
"error",
"erupt",
"escape",
"essay",
"essence",
"estate",
"eternal",
"ethics",
"evidence",
"evil",
"evoke",
"evolve",
"exact",
"example",
"excess",
"exchange",
"excite",
"exclude",
"excuse",
"execute",
"exercise",
"exhaust",
"exhibit",
"exile",
"exist",
"exit",
"exotic",
"expand",
"expect",
"expire",
"explain",
"expose",
"express",
"extend",
"extra",
"eye",
"eyebrow",
"fabric",
"face",
"faculty",
"fade",
"faint",
"faith",
"fall",
"false",
"fame",
"family",
"famous",
"fan",
"fancy",
"fantasy",
"farm",
"fashion",
"fat",
"fatal",
"father",
"fatigue",
"fault",
"favorite",
"feature",
"february",
"federal",
"fee",
"feed",
"feel",
"female",
"fence",
"festival",
"fetch",
"fever",
"few",
"fiber",
"fiction",
"field",
"figure",
"file",
"film",
"filter",
"final",
"find",
"fine",
"finger",
"finish",
"fire",
"firm",
"first",
"fiscal",
"fish",
"fit",
"fitness",
"fix",
"flag",
"flame",
"flash",
"flat",
"flavor",
"flee",
"flight",
"flip",
"float",
"flock",
"floor",
"flower",
"fluid",
"flush",
"fly",
"foam",
"focus",
"fog",
"foil",
"fold",
"follow",
"food",
"foot",
"force",
"forest",
"forget",
"fork",
"fortune",
"forum",
"forward",
"fossil",
"foster",
"found",
"fox",
"fragile",
"frame",
"frequent",
"fresh",
"friend",
"fringe",
"frog",
"front",
"frost",
"frown",
"frozen",
"fruit",
"fuel",
"fun",
"funny",
"furnace",
"fury",
"future",
"gadget",
"gain",
"galaxy",
"gallery",
"game",
"gap",
"garage",
"garbage",
"garden",
"garlic",
"garment",
"gas",
"gasp",
"gate",
"gather",
"gauge",
"gaze",
"general",
"genius",
"genre",
"gentle",
"genuine",
"gesture",
"ghost",
"giant",
"gift",
"giggle",
"ginger",
"giraffe",
"girl",
"give",
"glad",
"glance",
"glare",
"glass",
"glide",
"glimpse",
"globe",
"gloom",
"glory",
"glove",
"glow",
"glue",
"goat",
"goddess",
"gold",
"good",
"goose",
"gorilla",
"gospel",
"gossip",
"govern",
"gown",
"grab",
"grace",
"grain",
"grant",
"grape",
"grass",
"gravity",
"great",
"green",
"grid",
"grief",
"grit",
"grocery",
"group",
"grow",
"grunt",
"guard",
"guess",
"guide",
"guilt",
"guitar",
"gun",
"gym",
"habit",
"hair",
"half",
"hammer",
"hamster",
"hand",
"happy",
"harbor",
"hard",
"harsh",
"harvest",
"hat",
"have",
"hawk",
"hazard",
"head",
"health",
"heart",
"heavy",
"hedgehog",
"height",
"hello",
"helmet",
"help",
"hen",
"hero",
"hidden",
"high",
"hill",
"hint",
"hip",
"hire",
"history",
"hobby",
"hockey",
"hold",
"hole",
"holiday",
"hollow",
"home",
"honey",
"hood",
"hope",
"horn",
"horror",
"horse",
"hospital",
"host",
"hotel",
"hour",
"hover",
"hub",
"huge",
"human",
"humble",
"humor",
"hundred",
"hungry",
"hunt",
"hurdle",
"hurry",
"hurt",
"husband",
"hybrid",
"ice",
"icon",
"idea",
"identify",
"idle",
"ignore",
"ill",
"illegal",
"illness",
"image",
"imitate",
"immense",
"immune",
"impact",
"impose",
"improve",
"impulse",
"inch",
"include",
"income",
"increase",
"index",
"indicate",
"indoor",
"industry",
"infant",
"inflict",
"inform",
"inhale",
"inherit",
"initial",
"inject",
"injury",
"inmate",
"inner",
"innocent",
"input",
"inquiry",
"insane",
"insect",
"inside",
"inspire",
"install",
"intact",
"interest",
"into",
"invest",
"invite",
"involve",
"iron",
"island",
"isolate",
"issue",
"item",
"ivory",
"jacket",
"jaguar",
"jar",
"jazz",
"jealous",
"jeans",
"jelly",
"jewel",
"job",
"join",
"joke",
"journey",
"joy",
"judge",
"juice",
"jump",
"jungle",
"junior",
"junk",
"just",
"kangaroo",
"keen",
"keep",
"ketchup",
"key",
"kick",
"kid",
"kidney",
"kind",
"kingdom",
"kiss",
"kit",
"kitchen",
"kite",
"kitten",
"kiwi",
"knee",
"knife",
"knock",
"know",
"lab",
"label",
"labor",
"ladder",
"lady",
"lake",
"lamp",
"language",
"laptop",
"large",
"later",
"latin",
"laugh",
"laundry",
"lava",
"law",
"lawn",
"lawsuit",
"layer",
"lazy",
"leader",
"leaf",
"learn",
"leave",
"lecture",
"left",
"leg",
"legal",
"legend",
"leisure",
"lemon",
"lend",
"length",
"lens",
"leopard",
"lesson",
"letter",
"level",
"liar",
"liberty",
"library",
"license",
"life",
"lift",
"light",
"like",
"limb",
"limit",
"link",
"lion",
"liquid",
"list",
"little",
"live",
"lizard",
"load",
"loan",
"lobster",
"local",
"lock",
"logic",
"lonely",
"long",
"loop",
"lottery",
"loud",
"lounge",
"love",
"loyal",
"lucky",
"luggage",
"lumber",
"lunar",
"lunch",
"luxury",
"lyrics",
"machine",
"mad",
"magic",
"magnet",
"maid",
"mail",
"main",
"major",
"make",
"mammal",
"man",
"manage",
"mandate",
"mango",
"mansion",
"manual",
"maple",
"marble",
"march",
"margin",
"marine",
"market",
"marriage",
"mask",
"mass",
"master",
"match",
"material",
"math",
"matrix",
"matter",
"maximum",
"maze",
"meadow",
"mean",
"measure",
"meat",
"mechanic",
"medal",
"media",
"melody",
"melt",
"member",
"memory",
"mention",
"menu",
"mercy",
"merge",
"merit",
"merry",
"mesh",
"message",
"metal",
"method",
"middle",
"midnight",
"milk",
"million",
"mimic",
"mind",
"minimum",
"minor",
"minute",
"miracle",
"mirror",
"misery",
"miss",
"mistake",
"mix",
"mixed",
"mixture",
"mobile",
"model",
"modify",
"mom",
"moment",
"monitor",
"monkey",
"monster",
"month",
"moon",
"moral",
"more",
"morning",
"mosquito",
"mother",
"motion",
"motor",
"mountain",
"mouse",
"move",
"movie",
"much",
"muffin",
"mule",
"multiply",
"muscle",
"museum",
"mushroom",
"music",
"must",
"mutual",
"myself",
"mystery",
"myth",
"naive",
"name",
"napkin",
"narrow",
"nasty",
"nation",
"nature",
"near",
"neck",
"need",
"negative",
"neglect",
"neither",
"nephew",
"nerve",
"nest",
"net",
"network",
"neutral",
"never",
"news",
"next",
"nice",
"night",
"noble",
"noise",
"nominee",
"noodle",
"normal",
"north",
"nose",
"notable",
"note",
"nothing",
"notice",
"novel",
"now",
"nuclear",
"number",
"nurse",
"nut",
"oak",
"obey",
"object",
"oblige",
"obscure",
"observe",
"obtain",
"obvious",
"occur",
"ocean",
"october",
"odor",
"off",
"offer",
"office",
"often",
"oil",
"okay",
"old",
"olive",
"olympic",
"omit",
"once",
"one",
"onion",
"online",
"only",
"open",
"opera",
"opinion",
"oppose",
"option",
"orange",
"orbit",
"orchard",
"order",
"ordinary",
"organ",
"orient",
"original",
"orphan",
"ostrich",
"other",
"outdoor",
"outer",
"output",
"outside",
"oval",
"oven",
"over",
"own",
"owner",
"oxygen",
"oyster",
"ozone",
"pact",
"paddle",
"page",
"pair",
"palace",
"palm",
"panda",
"panel",
"panic",
"panther",
"paper",
"parade",
"parent",
"park",
"parrot",
"party",
"pass",
"patch",
"path",
"patient",
"patrol",
"pattern",
"pause",
"pave",
"payment",
"peace",
"peanut",
"pear",
"peasant",
"pelican",
"pen",
"penalty",
"pencil",
"people",
"pepper",
"perfect",
"permit",
"person",
"pet",
"phone",
"photo",
"phrase",
"physical",
"piano",
"picnic",
"picture",
"piece",
"pig",
"pigeon",
"pill",
"pilot",
"pink",
"pioneer",
"pipe",
"pistol",
"pitch",
"pizza",
"place",
"planet",
"plastic",
"plate",
"play",
"please",
"pledge",
"pluck",
"plug",
"plunge",
"poem",
"poet",
"point",
"polar",
"pole",
"police",
"pond",
"pony",
"pool",
"popular",
"portion",
"position",
"possible",
"post",
"potato",
"pottery",
"poverty",
"powder",
"power",
"practice",
"praise",
"predict",
"prefer",
"prepare",
"present",
"pretty",
"prevent",
"price",
"pride",
"primary",
"print",
"priority",
"prison",
"private",
"prize",
"problem",
"process",
"produce",
"profit",
"program",
"project",
"promote",
"proof",
"property",
"prosper",
"protect",
"proud",
"provide",
"public",
"pudding",
"pull",
"pulp",
"pulse",
"pumpkin",
"punch",
"pupil",
"puppy",
"purchase",
"purity",
"purpose",
"purse",
"push",
"put",
"puzzle",
"pyramid",
"quality",
"quantum",
"quarter",
"question",
"quick",
"quit",
"quiz",
"quote",
"rabbit",
"raccoon",
"race",
"rack",
"radar",
"radio",
"rail",
"rain",
"raise",
"rally",
"ramp",
"ranch",
"random",
"range",
"rapid",
"rare",
"rate",
"rather",
"raven",
"raw",
"razor",
"ready",
"real",
"reason",
"rebel",
"rebuild",
"recall",
"receive",
"recipe",
"record",
"recycle",
"reduce",
"reflect",
"reform",
"refuse",
"region",
"regret",
"regular",
"reject",
"relax",
"release",
"relief",
"rely",
"remain",
"remember",
"remind",
"remove",
"render",
"renew",
"rent",
"reopen",
"repair",
"repeat",
"replace",
"report",
"require",
"rescue",
"resemble",
"resist",
"resource",
"response",
"result",
"retire",
"retreat",
"return",
"reunion",
"reveal",
"review",
"reward",
"rhythm",
"rib",
"ribbon",
"rice",
"rich",
"ride",
"ridge",
"rifle",
"right",
"rigid",
"ring",
"riot",
"ripple",
"risk",
"ritual",
"rival",
"river",
"road",
"roast",
"robot",
"robust",
"rocket",
"romance",
"roof",
"rookie",
"room",
"rose",
"rotate",
"rough",
"round",
"route",
"royal",
"rubber",
"rude",
"rug",
"rule",
"run",
"runway",
"rural",
"sad",
"saddle",
"sadness",
"safe",
"sail",
"salad",
"salmon",
"salon",
"salt",
"salute",
"same",
"sample",
"sand",
"satisfy",
"satoshi",
"sauce",
"sausage",
"save",
"say",
"scale",
"scan",
"scare",
"scatter",
"scene",
"scheme",
"school",
"science",
"scissors",
"scorpion",
"scout",
"scrap",
"screen",
"script",
"scrub",
"sea",
"search",
"season",
"seat",
"second",
"secret",
"section",
"security",
"seed",
"seek",
"segment",
"select",
"sell",
"seminar",
"senior",
"sense",
"sentence",
"series",
"service",
"session",
"settle",
"setup",
"seven",
"shadow",
"shaft",
"shallow",
"share",
"shed",
"shell",
"sheriff",
"shield",
"shift",
"shine",
"ship",
"shiver",
"shock",
"shoe",
"shoot",
"shop",
"short",
"shoulder",
"shove",
"shrimp",
"shrug",
"shuffle",
"shy",
"sibling",
"sick",
"side",
"siege",
"sight",
"sign",
"silent",
"silk",
"silly",
"silver",
"similar",
"simple",
"since",
"sing",
"siren",
"sister",
"situate",
"six",
"size",
"skate",
"sketch",
"ski",
"skill",
"skin",
"skirt",
"skull",
"slab",
"slam",
"sleep",
"slender",
"slice",
"slide",
"slight",
"slim",
"slogan",
"slot",
"slow",
"slush",
"small",
"smart",
"smile",
"smoke",
"smooth",
"snack",
"snake",
"snap",
"sniff",
"snow",
"soap",
"soccer",
"social",
"sock",
"soda",
"soft",
"solar",
"soldier",
"solid",
"solution",
"solve",
"someone",
"song",
"soon",
"sorry",
"sort",
"soul",
"sound",
"soup",
"source",
"south",
"space",
"spare",
"spatial",
"spawn",
"speak",
"special",
"speed",
"spell",
"spend",
"sphere",
"spice",
"spider",
"spike",
"spin",
"spirit",
"split",
"spoil",
"sponsor",
"spoon",
"sport",
"spot",
"spray",
"spread",
"spring",
"spy",
"square",
"squeeze",
"squirrel",
"stable",
"stadium",
"staff",
"stage",
"stairs",
"stamp",
"stand",
"start",
"state",
"stay",
"steak",
"steel",
"stem",
"step",
"stereo",
"stick",
"still",
"sting",
"stock",
"stomach",
"stone",
"stool",
"story",
"stove",
"strategy",
"street",
"strike",
"strong",
"struggle",
"student",
"stuff",
"stumble",
"style",
"subject",
"submit",
"subway",
"success",
"such",
"sudden",
"suffer",
"sugar",
"suggest",
"suit",
"summer",
"sun",
"sunny",
"sunset",
"super",
"supply",
"supreme",
"sure",
"surface",
"surge",
"surprise",
"surround",
"survey",
"suspect",
"sustain",
"swallow",
"swamp",
"swap",
"swarm",
"swear",
"sweet",
"swift",
"swim",
"swing",
"switch",
"sword",
"symbol",
"symptom",
"syrup",
"system",
"table",
"tackle",
"tag",
"tail",
"talent",
"talk",
"tank",
"tape",
"target",
"task",
"taste",
"tattoo",
"taxi",
"teach",
"team",
"tell",
"ten",
"tenant",
"tennis",
"tent",
"term",
"test",
"text",
"thank",
"that",
"theme",
"then",
"theory",
"there",
"they",
"thing",
"this",
"thought",
"three",
"thrive",
"throw",
"thumb",
"thunder",
"ticket",
"tide",
"tiger",
"tilt",
"timber",
"time",
"tiny",
"tip",
"tired",
"tissue",
"title",
"toast",
"tobacco",
"today",
"toddler",
"toe",
"together",
"toilet",
"token",
"tomato",
"tomorrow",
"tone",
"tongue",
"tonight",
"tool",
"tooth",
"top",
"topic",
"topple",
"torch",
"tornado",
"tortoise",
"toss",
"total",
"tourist",
"toward",
"tower",
"town",
"toy",
"track",
"trade",
"traffic",
"tragic",
"train",
"transfer",
"trap",
"trash",
"travel",
"tray",
"treat",
"tree",
"trend",
"trial",
"tribe",
"trick",
"trigger",
"trim",
"trip",
"trophy",
"trouble",
"truck",
"true",
"truly",
"trumpet",
"trust",
"truth",
"try",
"tube",
"tuition",
"tumble",
"tuna",
"tunnel",
"turkey",
"turn",
"turtle",
"twelve",
"twenty",
"twice",
"twin",
"twist",
"two",
"type",
"typical",
"ugly",
"umbrella",
"unable",
"unaware",
"uncle",
"uncover",
"under",
"undo",
"unfair",
"unfold",
"unhappy",
"uniform",
"unique",
"unit",
"universe",
"unknown",
"unlock",
"until",
"unusual",
"unveil",
"update",
"upgrade",
"uphold",
"upon",
"upper",
"upset",
"urban",
"urge",
"usage",
"use",
"used",
"useful",
"useless",
"usual",
"utility",
"vacant",
"vacuum",
"vague",
"valid",
"valley",
"valve",
"van",
"vanish",
"vapor",
"various",
"vast",
"vault",
"vehicle",
"velvet",
"vendor",
"venture",
"venue",
"verb",
"verify",
"version",
"very",
"vessel",
"veteran",
"viable",
"vibrant",
"vicious",
"victory",
"video",
"view",
"village",
"vintage",
"violin",
"virtual",
"virus",
"visa",
"visit",
"visual",
"vital",
"vivid",
"vocal",
"voice",
"void",
"volcano",
"volume",
"vote",
"voyage",
"wage",
"wagon",
"wait",
"walk",
"wall",
"walnut",
"want",
"warfare",
"warm",
"warrior",
"wash",
"wasp",
"waste",
"water",
"wave",
"way",
"wealth",
"weapon",
"wear",
"weasel",
"weather",
"web",
"wedding",
"weekend",
"weird",
"welcome",
"west",
"wet",
"whale",
"what",
"wheat",
"wheel",
"when",
"where",
"whip",
"whisper",
"wide",
"width",
"wife",
"wild",
"will",
"win",
"window",
"wine",
"wing",
"wink",
"winner",
"winter",
"wire",
"wisdom",
"wise",
"wish",
"witness",
"wolf",
"woman",
"wonder",
"wood",
"wool",
"word",
"work",
"world",
"worry",
"worth",
"wrap",
"wreck",
"wrestle",
"wrist",
"write",
"wrong",
"yard",
"year",
"yellow",
"you",
"young",
"youth",
"zebra",
"zero",
"zone",
"zoo",
];
function bytesToBitstring(bytes) {
return Array.from(bytes)
.map((byte) => byte.toString(2).padStart(8, "0"))
.join("");
}
function deriveChecksumBits(entropy) {
const entropyLengthBits = entropy.length * 8; // "ENT" (in bits)
const checksumLengthBits = entropyLengthBits / 32; // "CS" (in bits)
const hash = (0, sha_1.sha256)(entropy);
return bytesToBitstring(hash).slice(0, checksumLengthBits);
}
function bitstringToByte(bin) {
return parseInt(bin, 2);
}
const allowedEntropyLengths = [16, 20, 24, 28, 32];
const allowedWordLengths = [12, 15, 18, 21, 24];
function entropyToMnemonic(entropy) {
if (allowedEntropyLengths.indexOf(entropy.length) === -1) {
throw new Error("invalid input length");
}
const entropyBits = bytesToBitstring(entropy);
const checksumBits = deriveChecksumBits(entropy);
const bits = entropyBits + checksumBits;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const chunks = bits.match(/(.{11})/g);
const words = chunks.map((binary) => {
const index = bitstringToByte(binary);
return wordlist[index];
});
return words.join(" ");
}
exports.entropyToMnemonic = entropyToMnemonic;
const invalidNumberOfWorks = "Invalid number of words";
const wordNotInWordlist = "Found word that is not in the wordlist";
const invalidEntropy = "Invalid entropy";
const invalidChecksum = "Invalid mnemonic checksum";
function normalize(str) {
return str.normalize("NFKD");
}
function mnemonicToEntropy(mnemonic) {
const words = normalize(mnemonic).split(" ");
if (!allowedWordLengths.includes(words.length)) {
throw new Error(invalidNumberOfWorks);
}
// convert word indices to 11 bit binary strings
const bits = words
.map((word) => {
const index = wordlist.indexOf(word);
if (index === -1) {
throw new Error(wordNotInWordlist);
}
return index.toString(2).padStart(11, "0");
})
.join("");
// split the binary string into ENT/CS
const dividerIndex = Math.floor(bits.length / 33) * 32;
const entropyBits = bits.slice(0, dividerIndex);
const checksumBits = bits.slice(dividerIndex);
// calculate the checksum and compare
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const entropyBytes = entropyBits.match(/(.{1,8})/g).map(bitstringToByte);
if (entropyBytes.length < 16 || entropyBytes.length > 32 || entropyBytes.length % 4 !== 0) {
throw new Error(invalidEntropy);
}
const entropy = Uint8Array.from(entropyBytes);
const newChecksum = deriveChecksumBits(entropy);
if (newChecksum !== checksumBits) {
throw new Error(invalidChecksum);
}
return entropy;
}
exports.mnemonicToEntropy = mnemonicToEntropy;
class EnglishMnemonic {
constructor(mnemonic) {
if (!EnglishMnemonic.mnemonicMatcher.test(mnemonic)) {
throw new Error("Invalid mnemonic format");
}
const words = mnemonic.split(" ");
const allowedWordsLengths = [12, 15, 18, 21, 24];
if (allowedWordsLengths.indexOf(words.length) === -1) {
throw new Error(`Invalid word count in mnemonic (allowed: ${allowedWordsLengths} got: ${words.length})`);
}
for (const word of words) {
if (EnglishMnemonic.wordlist.indexOf(word) === -1) {
throw new Error("Mnemonic contains invalid word");
}
}
// Throws with informative error message if mnemonic is not valid
mnemonicToEntropy(mnemonic);
this.data = mnemonic;
}
toString() {
return this.data;
}
}
exports.EnglishMnemonic = EnglishMnemonic;
EnglishMnemonic.wordlist = wordlist;
// list of space separated lower case words (1 or more)
EnglishMnemonic.mnemonicMatcher = /^[a-z]+( [a-z]+)*$/;
class Bip39 {

@@ -43,13 +2173,12 @@ /**

static encode(entropy) {
const allowedEntropyLengths = [16, 20, 24, 28, 32];
if (allowedEntropyLengths.indexOf(entropy.length) === -1) {
throw new Error("invalid input length");
}
return new englishmnemonic_1.EnglishMnemonic(bip39.entropyToMnemonic(encoding_1.toHex(entropy)));
return new EnglishMnemonic(entropyToMnemonic(entropy));
}
static decode(mnemonic) {
return encoding_1.fromHex(bip39.mnemonicToEntropy(mnemonic.toString()));
return mnemonicToEntropy(mnemonic.toString());
}
static async mnemonicToSeed(mnemonic, password) {
return new Uint8Array(await bip39.mnemonicToSeed(mnemonic.toString(), password));
const mnemonicBytes = (0, encoding_1.toUtf8)(normalize(mnemonic.toString()));
const salt = "mnemonic" + (password ? normalize(password) : "");
const saltBytes = (0, encoding_1.toUtf8)(salt);
return (0, pbkdf2_1.pbkdf2Sha512)(mnemonicBytes, saltBytes, 2048, 64);
}

@@ -56,0 +2185,0 @@ }

196

build/bip39.spec.js

@@ -8,4 +8,35 @@ "use strict";

const bip39_1 = require("./bip39");
const englishmnemonic_1 = require("./englishmnemonic");
const sha_1 = require("./sha");
const bip39_json_1 = __importDefault(require("./testdata/bip39.json"));
const bip39_wordlists_json_1 = __importDefault(require("./testdata/bip39_wordlists.json"));
describe("entropyToMnemonic", () => {
it("works", () => {
// From https://iancoleman.io/bip39/
expect((0, bip39_1.entropyToMnemonic)((0, encoding_1.fromHex)("a323224e6b13d31942509dc4e2e579be3d5bb7f2"))).toEqual("permit boil near stomach diamond million announce beauty shaft blame fury ladder stick swim slab");
});
it("works for all the test vectors", () => {
// Test vectors from https://github.com/trezor/python-mnemonic/blob/b502451a33a440783926e04428115e0bed87d01f/vectors.json
// plus similar vectors generated for the missing lengths 15 and 21 words
const { "12": vec12, "15": vec15, "18": vec18, "21": vec21, "24": vec24 } = bip39_json_1.default.encoding;
for (const vectors of [vec12, vec15, vec18, vec21, vec24]) {
for (const { entropy, mnemonic } of vectors) {
expect((0, bip39_1.entropyToMnemonic)((0, encoding_1.fromHex)(entropy)).toString()).toEqual(mnemonic);
}
}
});
});
describe("mnemonicToEntropy", () => {
it("works", () => {
// From https://iancoleman.io/bip39/
expect((0, bip39_1.mnemonicToEntropy)("permit boil near stomach diamond million announce beauty shaft blame fury ladder stick swim slab")).toEqual((0, encoding_1.fromHex)("a323224e6b13d31942509dc4e2e579be3d5bb7f2"));
});
it("works for all the test vectors", () => {
const { "12": vec12, "15": vec15, "18": vec18, "21": vec21, "24": vec24 } = bip39_json_1.default.encoding;
for (const vectors of [vec12, vec15, vec18, vec21, vec24]) {
for (const { entropy, mnemonic } of vectors) {
expect((0, bip39_1.mnemonicToEntropy)(mnemonic)).toEqual((0, encoding_1.fromHex)(entropy));
}
}
});
});
describe("Bip39", () => {

@@ -19,3 +50,3 @@ describe("encode", () => {

for (const { entropy, mnemonic } of vectors) {
expect(bip39_1.Bip39.encode(encoding_1.fromHex(entropy)).toString()).toEqual(mnemonic);
expect(bip39_1.Bip39.encode((0, encoding_1.fromHex)(entropy)).toString()).toEqual(mnemonic);
}

@@ -26,10 +57,10 @@ }

// invalid input length
expect(() => bip39_1.Bip39.encode(encoding_1.fromHex(""))).toThrowError(/invalid input length/);
expect(() => bip39_1.Bip39.encode(encoding_1.fromHex("00"))).toThrowError(/invalid input length/);
expect(() => bip39_1.Bip39.encode(encoding_1.fromHex("000000000000000000000000000000"))).toThrowError(/invalid input length/);
expect(() => bip39_1.Bip39.encode(encoding_1.fromHex("0000000000000000000000000000000000"))).toThrowError(/invalid input length/);
expect(() => bip39_1.Bip39.encode(encoding_1.fromHex("0000000000000000000000000000000000000000000000"))).toThrowError(/invalid input length/);
expect(() => bip39_1.Bip39.encode(encoding_1.fromHex("00000000000000000000000000000000000000000000000000"))).toThrowError(/invalid input length/);
expect(() => bip39_1.Bip39.encode(encoding_1.fromHex("00000000000000000000000000000000000000000000000000000000000000"))).toThrowError(/invalid input length/);
expect(() => bip39_1.Bip39.encode(encoding_1.fromHex("000000000000000000000000000000000000000000000000000000000000000000"))).toThrowError(/invalid input length/);
expect(() => bip39_1.Bip39.encode((0, encoding_1.fromHex)(""))).toThrowError(/invalid input length/);
expect(() => bip39_1.Bip39.encode((0, encoding_1.fromHex)("00"))).toThrowError(/invalid input length/);
expect(() => bip39_1.Bip39.encode((0, encoding_1.fromHex)("000000000000000000000000000000"))).toThrowError(/invalid input length/);
expect(() => bip39_1.Bip39.encode((0, encoding_1.fromHex)("0000000000000000000000000000000000"))).toThrowError(/invalid input length/);
expect(() => bip39_1.Bip39.encode((0, encoding_1.fromHex)("0000000000000000000000000000000000000000000000"))).toThrowError(/invalid input length/);
expect(() => bip39_1.Bip39.encode((0, encoding_1.fromHex)("00000000000000000000000000000000000000000000000000"))).toThrowError(/invalid input length/);
expect(() => bip39_1.Bip39.encode((0, encoding_1.fromHex)("00000000000000000000000000000000000000000000000000000000000000"))).toThrowError(/invalid input length/);
expect(() => bip39_1.Bip39.encode((0, encoding_1.fromHex)("000000000000000000000000000000000000000000000000000000000000000000"))).toThrowError(/invalid input length/);
});

@@ -42,3 +73,3 @@ });

for (const { entropy, mnemonic } of vectors) {
expect(bip39_1.Bip39.decode(new englishmnemonic_1.EnglishMnemonic(mnemonic))).toEqual(encoding_1.fromHex(entropy));
expect(bip39_1.Bip39.decode(new bip39_1.EnglishMnemonic(mnemonic))).toEqual((0, encoding_1.fromHex)(entropy));
}

@@ -50,26 +81,26 @@ }

it("can calculate seed from mnemonic (trezor test vectors)", async () => {
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"), "TREZOR")).toEqual(encoding_1.fromHex("c55257c360c07c72029aebc1b53c05ed0362ada38ead3e3e9efa3708e53495531f09a6987599d18264c1e1c92f2cf141630c7a3c4ab7c81b2f001698e7463b04"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("legal winner thank year wave sausage worth useful legal winner thank yellow"), "TREZOR")).toEqual(encoding_1.fromHex("2e8905819b8723fe2c1d161860e5ee1830318dbf49a83bd451cfb8440c28bd6fa457fe1296106559a3c80937a1c1069be3a3a5bd381ee6260e8d9739fce1f607"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("letter advice cage absurd amount doctor acoustic avoid letter advice cage above"), "TREZOR")).toEqual(encoding_1.fromHex("d71de856f81a8acc65e6fc851a38d4d7ec216fd0796d0a6827a3ad6ed5511a30fa280f12eb2e47ed2ac03b5c462a0358d18d69fe4f985ec81778c1b370b652a8"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong"), "TREZOR")).toEqual(encoding_1.fromHex("ac27495480225222079d7be181583751e86f571027b0497b5b5d11218e0a8a13332572917f0f8e5a589620c6f15b11c61dee327651a14c34e18231052e48c069"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon agent"), "TREZOR")).toEqual(encoding_1.fromHex("035895f2f481b1b0f01fcf8c289c794660b289981a78f8106447707fdd9666ca06da5a9a565181599b79f53b844d8a71dd9f439c52a3d7b3e8a79c906ac845fa"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("legal winner thank year wave sausage worth useful legal winner thank year wave sausage worth useful legal will"), "TREZOR")).toEqual(encoding_1.fromHex("f2b94508732bcbacbcc020faefecfc89feafa6649a5491b8c952cede496c214a0c7b3c392d168748f2d4a612bada0753b52a1c7ac53c1e93abd5c6320b9e95dd"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic avoid letter always"), "TREZOR")).toEqual(encoding_1.fromHex("107d7c02a5aa6f38c58083ff74f04c607c2d2c0ecc55501dadd72d025b751bc27fe913ffb796f841c49b1d33b610cf0e91d3aa239027f5e99fe4ce9e5088cd65"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo when"), "TREZOR")).toEqual(encoding_1.fromHex("0cd6e5d827bb62eb8fc1e262254223817fd068a74b5b449cc2f667c3f1f985a76379b43348d952e2265b4cd129090758b3e3c2c49103b5051aac2eaeb890a528"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art"), "TREZOR")).toEqual(encoding_1.fromHex("bda85446c68413707090a52022edd26a1c9462295029f2e60cd7c4f2bbd3097170af7a4d73245cafa9c3cca8d561a7c3de6f5d4a10be8ed2a5e608d68f92fcc8"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("legal winner thank year wave sausage worth useful legal winner thank year wave sausage worth useful legal winner thank year wave sausage worth title"), "TREZOR")).toEqual(encoding_1.fromHex("bc09fca1804f7e69da93c2f2028eb238c227f2e9dda30cd63699232578480a4021b146ad717fbb7e451ce9eb835f43620bf5c514db0f8add49f5d121449d3e87"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic bless"), "TREZOR")).toEqual(encoding_1.fromHex("c0c519bd0e91a2ed54357d9d1ebef6f5af218a153624cf4f2da911a0ed8f7a09e2ef61af0aca007096df430022f7a2b6fb91661a9589097069720d015e4e982f"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo vote"), "TREZOR")).toEqual(encoding_1.fromHex("dd48c104698c30cfe2b6142103248622fb7bb0ff692eebb00089b32d22484e1613912f0a5b694407be899ffd31ed3992c456cdf60f5d4564b8ba3f05a69890ad"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("ozone drill grab fiber curtain grace pudding thank cruise elder eight picnic"), "TREZOR")).toEqual(encoding_1.fromHex("274ddc525802f7c828d8ef7ddbcdc5304e87ac3535913611fbbfa986d0c9e5476c91689f9c8a54fd55bd38606aa6a8595ad213d4c9c9f9aca3fb217069a41028"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("gravity machine north sort system female filter attitude volume fold club stay feature office ecology stable narrow fog"), "TREZOR")).toEqual(encoding_1.fromHex("628c3827a8823298ee685db84f55caa34b5cc195a778e52d45f59bcf75aba68e4d7590e101dc414bc1bbd5737666fbbef35d1f1903953b66624f910feef245ac"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("hamster diagram private dutch cause delay private meat slide toddler razor book happy fancy gospel tennis maple dilemma loan word shrug inflict delay length"), "TREZOR")).toEqual(encoding_1.fromHex("64c87cde7e12ecf6704ab95bb1408bef047c22db4cc7491c4271d170a1b213d20b385bc1588d9c7b38f1b39d415665b8a9030c9ec653d75e65f847d8fc1fc440"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("scheme spot photo card baby mountain device kick cradle pact join borrow"), "TREZOR")).toEqual(encoding_1.fromHex("ea725895aaae8d4c1cf682c1bfd2d358d52ed9f0f0591131b559e2724bb234fca05aa9c02c57407e04ee9dc3b454aa63fbff483a8b11de949624b9f1831a9612"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("horn tenant knee talent sponsor spell gate clip pulse soap slush warm silver nephew swap uncle crack brave"), "TREZOR")).toEqual(encoding_1.fromHex("fd579828af3da1d32544ce4db5c73d53fc8acc4ddb1e3b251a31179cdb71e853c56d2fcb11aed39898ce6c34b10b5382772db8796e52837b54468aeb312cfc3d"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("panda eyebrow bullet gorilla call smoke muffin taste mesh discover soft ostrich alcohol speed nation flash devote level hobby quick inner drive ghost inside"), "TREZOR")).toEqual(encoding_1.fromHex("72be8e052fc4919d2adf28d5306b5474b0069df35b02303de8c1729c9538dbb6fc2d731d5f832193cd9fb6aeecbc469594a70e3dd50811b5067f3b88b28c3e8d"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("cat swing flag economy stadium alone churn speed unique patch report train"), "TREZOR")).toEqual(encoding_1.fromHex("deb5f45449e615feff5640f2e49f933ff51895de3b4381832b3139941c57b59205a42480c52175b6efcffaa58a2503887c1e8b363a707256bdd2b587b46541f5"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("light rule cinnamon wrap drastic word pride squirrel upgrade then income fatal apart sustain crack supply proud access"), "TREZOR")).toEqual(encoding_1.fromHex("4cbdff1ca2db800fd61cae72a57475fdc6bab03e441fd63f96dabd1f183ef5b782925f00105f318309a7e9c3ea6967c7801e46c8a58082674c860a37b93eda02"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("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")).toEqual(encoding_1.fromHex("26e975ec644423f4a4c4f4215ef09b4bd7ef924e85d1d17c4cf3f136c2863cf6df0a475045652c57eb5fb41513ca2a2d67722b77e954b4b3fc11f7590449191d"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("vessel ladder alter error federal sibling chat ability sun glass valve picture"), "TREZOR")).toEqual(encoding_1.fromHex("2aaa9242daafcee6aa9d7269f17d4efe271e1b9a529178d7dc139cd18747090bf9d60295d0ce74309a78852a9caadf0af48aae1c6253839624076224374bc63f"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("scissors invite lock maple supreme raw rapid void congress muscle digital elegant little brisk hair mango congress clump"), "TREZOR")).toEqual(encoding_1.fromHex("7b4a10be9d98e6cba265566db7f136718e1398c71cb581e1b2f464cac1ceedf4f3e274dc270003c670ad8d02c4558b2f8e39edea2775c9e232c7cb798b069e88"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("void come effort suffer camp survey warrior heavy shoot primary clutch crush open amazing screen patrol group space point ten exist slush involve unfold"), "TREZOR")).toEqual(encoding_1.fromHex("01f5bced59dec48e362f2c45b5de68b9fd6c92c6634f44d6d40aab69056506f0e35524a518034ddc1192e1dacd32c1ed3eaa3c3b131c88ed8e7e54c49a5d0998"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"), "TREZOR")).toEqual((0, encoding_1.fromHex)("c55257c360c07c72029aebc1b53c05ed0362ada38ead3e3e9efa3708e53495531f09a6987599d18264c1e1c92f2cf141630c7a3c4ab7c81b2f001698e7463b04"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("legal winner thank year wave sausage worth useful legal winner thank yellow"), "TREZOR")).toEqual((0, encoding_1.fromHex)("2e8905819b8723fe2c1d161860e5ee1830318dbf49a83bd451cfb8440c28bd6fa457fe1296106559a3c80937a1c1069be3a3a5bd381ee6260e8d9739fce1f607"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("letter advice cage absurd amount doctor acoustic avoid letter advice cage above"), "TREZOR")).toEqual((0, encoding_1.fromHex)("d71de856f81a8acc65e6fc851a38d4d7ec216fd0796d0a6827a3ad6ed5511a30fa280f12eb2e47ed2ac03b5c462a0358d18d69fe4f985ec81778c1b370b652a8"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong"), "TREZOR")).toEqual((0, encoding_1.fromHex)("ac27495480225222079d7be181583751e86f571027b0497b5b5d11218e0a8a13332572917f0f8e5a589620c6f15b11c61dee327651a14c34e18231052e48c069"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon agent"), "TREZOR")).toEqual((0, encoding_1.fromHex)("035895f2f481b1b0f01fcf8c289c794660b289981a78f8106447707fdd9666ca06da5a9a565181599b79f53b844d8a71dd9f439c52a3d7b3e8a79c906ac845fa"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("legal winner thank year wave sausage worth useful legal winner thank year wave sausage worth useful legal will"), "TREZOR")).toEqual((0, encoding_1.fromHex)("f2b94508732bcbacbcc020faefecfc89feafa6649a5491b8c952cede496c214a0c7b3c392d168748f2d4a612bada0753b52a1c7ac53c1e93abd5c6320b9e95dd"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic avoid letter always"), "TREZOR")).toEqual((0, encoding_1.fromHex)("107d7c02a5aa6f38c58083ff74f04c607c2d2c0ecc55501dadd72d025b751bc27fe913ffb796f841c49b1d33b610cf0e91d3aa239027f5e99fe4ce9e5088cd65"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo when"), "TREZOR")).toEqual((0, encoding_1.fromHex)("0cd6e5d827bb62eb8fc1e262254223817fd068a74b5b449cc2f667c3f1f985a76379b43348d952e2265b4cd129090758b3e3c2c49103b5051aac2eaeb890a528"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art"), "TREZOR")).toEqual((0, encoding_1.fromHex)("bda85446c68413707090a52022edd26a1c9462295029f2e60cd7c4f2bbd3097170af7a4d73245cafa9c3cca8d561a7c3de6f5d4a10be8ed2a5e608d68f92fcc8"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("legal winner thank year wave sausage worth useful legal winner thank year wave sausage worth useful legal winner thank year wave sausage worth title"), "TREZOR")).toEqual((0, encoding_1.fromHex)("bc09fca1804f7e69da93c2f2028eb238c227f2e9dda30cd63699232578480a4021b146ad717fbb7e451ce9eb835f43620bf5c514db0f8add49f5d121449d3e87"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic avoid letter advice cage absurd amount doctor acoustic bless"), "TREZOR")).toEqual((0, encoding_1.fromHex)("c0c519bd0e91a2ed54357d9d1ebef6f5af218a153624cf4f2da911a0ed8f7a09e2ef61af0aca007096df430022f7a2b6fb91661a9589097069720d015e4e982f"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo vote"), "TREZOR")).toEqual((0, encoding_1.fromHex)("dd48c104698c30cfe2b6142103248622fb7bb0ff692eebb00089b32d22484e1613912f0a5b694407be899ffd31ed3992c456cdf60f5d4564b8ba3f05a69890ad"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("ozone drill grab fiber curtain grace pudding thank cruise elder eight picnic"), "TREZOR")).toEqual((0, encoding_1.fromHex)("274ddc525802f7c828d8ef7ddbcdc5304e87ac3535913611fbbfa986d0c9e5476c91689f9c8a54fd55bd38606aa6a8595ad213d4c9c9f9aca3fb217069a41028"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("gravity machine north sort system female filter attitude volume fold club stay feature office ecology stable narrow fog"), "TREZOR")).toEqual((0, encoding_1.fromHex)("628c3827a8823298ee685db84f55caa34b5cc195a778e52d45f59bcf75aba68e4d7590e101dc414bc1bbd5737666fbbef35d1f1903953b66624f910feef245ac"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("hamster diagram private dutch cause delay private meat slide toddler razor book happy fancy gospel tennis maple dilemma loan word shrug inflict delay length"), "TREZOR")).toEqual((0, encoding_1.fromHex)("64c87cde7e12ecf6704ab95bb1408bef047c22db4cc7491c4271d170a1b213d20b385bc1588d9c7b38f1b39d415665b8a9030c9ec653d75e65f847d8fc1fc440"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("scheme spot photo card baby mountain device kick cradle pact join borrow"), "TREZOR")).toEqual((0, encoding_1.fromHex)("ea725895aaae8d4c1cf682c1bfd2d358d52ed9f0f0591131b559e2724bb234fca05aa9c02c57407e04ee9dc3b454aa63fbff483a8b11de949624b9f1831a9612"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("horn tenant knee talent sponsor spell gate clip pulse soap slush warm silver nephew swap uncle crack brave"), "TREZOR")).toEqual((0, encoding_1.fromHex)("fd579828af3da1d32544ce4db5c73d53fc8acc4ddb1e3b251a31179cdb71e853c56d2fcb11aed39898ce6c34b10b5382772db8796e52837b54468aeb312cfc3d"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("panda eyebrow bullet gorilla call smoke muffin taste mesh discover soft ostrich alcohol speed nation flash devote level hobby quick inner drive ghost inside"), "TREZOR")).toEqual((0, encoding_1.fromHex)("72be8e052fc4919d2adf28d5306b5474b0069df35b02303de8c1729c9538dbb6fc2d731d5f832193cd9fb6aeecbc469594a70e3dd50811b5067f3b88b28c3e8d"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("cat swing flag economy stadium alone churn speed unique patch report train"), "TREZOR")).toEqual((0, encoding_1.fromHex)("deb5f45449e615feff5640f2e49f933ff51895de3b4381832b3139941c57b59205a42480c52175b6efcffaa58a2503887c1e8b363a707256bdd2b587b46541f5"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("light rule cinnamon wrap drastic word pride squirrel upgrade then income fatal apart sustain crack supply proud access"), "TREZOR")).toEqual((0, encoding_1.fromHex)("4cbdff1ca2db800fd61cae72a57475fdc6bab03e441fd63f96dabd1f183ef5b782925f00105f318309a7e9c3ea6967c7801e46c8a58082674c860a37b93eda02"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("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")).toEqual((0, encoding_1.fromHex)("26e975ec644423f4a4c4f4215ef09b4bd7ef924e85d1d17c4cf3f136c2863cf6df0a475045652c57eb5fb41513ca2a2d67722b77e954b4b3fc11f7590449191d"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("vessel ladder alter error federal sibling chat ability sun glass valve picture"), "TREZOR")).toEqual((0, encoding_1.fromHex)("2aaa9242daafcee6aa9d7269f17d4efe271e1b9a529178d7dc139cd18747090bf9d60295d0ce74309a78852a9caadf0af48aae1c6253839624076224374bc63f"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("scissors invite lock maple supreme raw rapid void congress muscle digital elegant little brisk hair mango congress clump"), "TREZOR")).toEqual((0, encoding_1.fromHex)("7b4a10be9d98e6cba265566db7f136718e1398c71cb581e1b2f464cac1ceedf4f3e274dc270003c670ad8d02c4558b2f8e39edea2775c9e232c7cb798b069e88"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("void come effort suffer camp survey warrior heavy shoot primary clutch crush open amazing screen patrol group space point ten exist slush involve unfold"), "TREZOR")).toEqual((0, encoding_1.fromHex)("01f5bced59dec48e362f2c45b5de68b9fd6c92c6634f44d6d40aab69056506f0e35524a518034ddc1192e1dacd32c1ed3eaa3c3b131c88ed8e7e54c49a5d0998"));
});

@@ -86,12 +117,95 @@ it("can calculate seed from mnemonic (no password)", async () => {

// empty password
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("robust pipe raise illness symptom crowd trip will slow assault recipe oven"), "")).toEqual(encoding_1.fromHex("5539eed11e1096e9d52f69f15ad3d7c6547a40a3865b9517dbcbb03c31f231900622f58616d64d2d1cc0440f31d67fb0b2699a5fc885f796c746e0f844477093"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("pair ethics august street tornado spare present under capital raise cross current main craft stone clutch tray all"), "")).toEqual(encoding_1.fromHex("1272467e954cec4e0ad720002d037a3aaf795a57ffbeea6aaa0c242d410eb52050292447aa2c68470a07ecc80171edfa9e027793265047be3128d94e867a4f99"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("allow finger front connect strategy purchase journey distance trouble guitar honey alpha giraffe canal junk vintage chronic blade gate custom soap flip first mix"), "")).toEqual(encoding_1.fromHex("476a41ac016b5bdf9f114456929975a036ae326e2efdca441ac5a0949ef89ab9246dc9e49a5d2d64d1926eb9dbe17576cb010471c2a821b216202acdf3d7a27b"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("robust pipe raise illness symptom crowd trip will slow assault recipe oven"), "")).toEqual((0, encoding_1.fromHex)("5539eed11e1096e9d52f69f15ad3d7c6547a40a3865b9517dbcbb03c31f231900622f58616d64d2d1cc0440f31d67fb0b2699a5fc885f796c746e0f844477093"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("pair ethics august street tornado spare present under capital raise cross current main craft stone clutch tray all"), "")).toEqual((0, encoding_1.fromHex)("1272467e954cec4e0ad720002d037a3aaf795a57ffbeea6aaa0c242d410eb52050292447aa2c68470a07ecc80171edfa9e027793265047be3128d94e867a4f99"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("allow finger front connect strategy purchase journey distance trouble guitar honey alpha giraffe canal junk vintage chronic blade gate custom soap flip first mix"), "")).toEqual((0, encoding_1.fromHex)("476a41ac016b5bdf9f114456929975a036ae326e2efdca441ac5a0949ef89ab9246dc9e49a5d2d64d1926eb9dbe17576cb010471c2a821b216202acdf3d7a27b"));
// no password
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("robust pipe raise illness symptom crowd trip will slow assault recipe oven"))).toEqual(encoding_1.fromHex("5539eed11e1096e9d52f69f15ad3d7c6547a40a3865b9517dbcbb03c31f231900622f58616d64d2d1cc0440f31d67fb0b2699a5fc885f796c746e0f844477093"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("pair ethics august street tornado spare present under capital raise cross current main craft stone clutch tray all"))).toEqual(encoding_1.fromHex("1272467e954cec4e0ad720002d037a3aaf795a57ffbeea6aaa0c242d410eb52050292447aa2c68470a07ecc80171edfa9e027793265047be3128d94e867a4f99"));
expect(await bip39_1.Bip39.mnemonicToSeed(new englishmnemonic_1.EnglishMnemonic("allow finger front connect strategy purchase journey distance trouble guitar honey alpha giraffe canal junk vintage chronic blade gate custom soap flip first mix"))).toEqual(encoding_1.fromHex("476a41ac016b5bdf9f114456929975a036ae326e2efdca441ac5a0949ef89ab9246dc9e49a5d2d64d1926eb9dbe17576cb010471c2a821b216202acdf3d7a27b"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("robust pipe raise illness symptom crowd trip will slow assault recipe oven"))).toEqual((0, encoding_1.fromHex)("5539eed11e1096e9d52f69f15ad3d7c6547a40a3865b9517dbcbb03c31f231900622f58616d64d2d1cc0440f31d67fb0b2699a5fc885f796c746e0f844477093"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("pair ethics august street tornado spare present under capital raise cross current main craft stone clutch tray all"))).toEqual((0, encoding_1.fromHex)("1272467e954cec4e0ad720002d037a3aaf795a57ffbeea6aaa0c242d410eb52050292447aa2c68470a07ecc80171edfa9e027793265047be3128d94e867a4f99"));
expect(await bip39_1.Bip39.mnemonicToSeed(new bip39_1.EnglishMnemonic("allow finger front connect strategy purchase journey distance trouble guitar honey alpha giraffe canal junk vintage chronic blade gate custom soap flip first mix"))).toEqual((0, encoding_1.fromHex)("476a41ac016b5bdf9f114456929975a036ae326e2efdca441ac5a0949ef89ab9246dc9e49a5d2d64d1926eb9dbe17576cb010471c2a821b216202acdf3d7a27b"));
});
});
});
describe("EnglishMnemonic", () => {
describe("wordlist", () => {
it("matches the words from the bitcoin/bips/bip-0039 spec", () => {
const lineFeed = 0x0a;
const bip39EnglishTxt = (0, encoding_1.fromBase64)(bip39_wordlists_json_1.default.english);
// Ensure we loaded the correct english.txt from https://github.com/bitcoin/bips/tree/master/bip-0039
const checksum = (0, sha_1.sha256)(bip39EnglishTxt);
expect(checksum).toEqual((0, encoding_1.fromHex)("2f5eed53a4727b4bf8880d8f3f199efc90e58503646d9ff8eff3a2ed3b24dbda"));
const wordsFromSpec = [];
let start = 0; // the start cursor marks the first byte of the word
let end = 0; // the end cursor marks the line feed byte
while (end < bip39EnglishTxt.length - 1) {
end = start;
while (bip39EnglishTxt[end] !== lineFeed)
end++;
const slice = bip39EnglishTxt.slice(start, end);
wordsFromSpec.push((0, encoding_1.fromAscii)(slice));
start = end + 1;
}
expect(bip39_1.EnglishMnemonic.wordlist).toEqual(wordsFromSpec);
});
});
it("works for valid inputs", () => {
expect(() => {
new bip39_1.EnglishMnemonic("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about");
new bip39_1.EnglishMnemonic("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon address");
new bip39_1.EnglishMnemonic("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon agent");
new bip39_1.EnglishMnemonic("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon admit");
new bip39_1.EnglishMnemonic("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art");
}).not.toThrow();
});
it("rejects invalid whitespacing", () => {
// extra space (leading, middle, trailing)
expect(() => new bip39_1.EnglishMnemonic(" abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about")).toThrowError(/invalid mnemonic format/i);
expect(() => new bip39_1.EnglishMnemonic("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about")).toThrowError(/invalid mnemonic format/i);
expect(() => new bip39_1.EnglishMnemonic("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about ")).toThrowError(/invalid mnemonic format/i);
// newline, tab
expect(() => new bip39_1.EnglishMnemonic("abandon\nabandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about")).toThrowError(/invalid mnemonic format/i);
expect(() => new bip39_1.EnglishMnemonic("abandon\tabandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about")).toThrowError(/invalid mnemonic format/i);
});
it("rejects disallowed letters", () => {
// Disallowed letters in words (capital, number, special char)
expect(() => new bip39_1.EnglishMnemonic("Abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about")).toThrowError(/invalid mnemonic format/i);
expect(() => new bip39_1.EnglishMnemonic("abandon abandon Abandon abandon abandon abandon abandon abandon abandon abandon abandon about")).toThrowError(/invalid mnemonic format/i);
expect(() => new bip39_1.EnglishMnemonic("route66 abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about")).toThrowError(/invalid mnemonic format/i);
expect(() => new bip39_1.EnglishMnemonic("abandon abandon route66 abandon abandon abandon abandon abandon abandon abandon abandon about")).toThrowError(/invalid mnemonic format/i);
expect(() => new bip39_1.EnglishMnemonic("lötkolben abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about")).toThrowError(/invalid mnemonic format/i);
expect(() => new bip39_1.EnglishMnemonic("abandon abandon lötkolben abandon abandon abandon abandon abandon abandon abandon abandon about")).toThrowError(/invalid mnemonic format/i);
});
it("word counts other than 12, 15, 18, 21, 24", () => {
// too few and too many words (11, 13, 17, 19, 23, 25)
expect(() => new bip39_1.EnglishMnemonic("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about")).toThrowError(/invalid word count(.*)got: 11/i);
expect(() => new bip39_1.EnglishMnemonic("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about")).toThrowError(/invalid word count(.*)got: 13/i);
expect(() => new bip39_1.EnglishMnemonic("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon agent")).toThrowError(/invalid word count(.*)got: 17/i);
expect(() => new bip39_1.EnglishMnemonic("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon agent")).toThrowError(/invalid word count(.*)got: 19/i);
expect(() => new bip39_1.EnglishMnemonic("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art")).toThrowError(/invalid word count(.*)got: 23/i);
expect(() => new bip39_1.EnglishMnemonic("abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art")).toThrowError(/invalid word count(.*)got: 25/i);
});
it("rejects invalid checksums", () => {
// 12x, 15x, 18x, 21x, 24x "zoo"
expect(() => new bip39_1.EnglishMnemonic("zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo")).toThrowError(/invalid mnemonic checksum/i);
expect(() => new bip39_1.EnglishMnemonic("zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo")).toThrowError(/invalid mnemonic checksum/i);
expect(() => new bip39_1.EnglishMnemonic("zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo")).toThrowError(/invalid mnemonic checksum/i);
expect(() => new bip39_1.EnglishMnemonic("zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo")).toThrowError(/invalid mnemonic checksum/i);
expect(() => new bip39_1.EnglishMnemonic("zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo")).toThrowError(/invalid mnemonic checksum/i);
});
it("rejects valid mnemonics of other languages", () => {
// valid Spanish and Italian bip39 mnemonics
expect(() => new bip39_1.EnglishMnemonic("humo odio oriente colina taco fingir salto geranio glaciar academia suave vigor")).toThrowError(/contains invalid word/i);
expect(() => new bip39_1.EnglishMnemonic("yema folleto tos llave obtener natural fruta deseo laico sopa novato lazo imponer afinar vena hoja zarza cama")).toThrowError(/contains invalid word/i);
expect(() => new bip39_1.EnglishMnemonic("burla plaza arroz ronda pregunta vacuna veloz boina retiro exento prensa tortuga cabeza pilar anual molino molde fiesta masivo jefe leve fatiga clase plomo")).toThrowError(/contains invalid word/i);
expect(() => new bip39_1.EnglishMnemonic("braccio trincea armonia emiro svedese lepre stridulo metallo baldo rasente potassio rilassato")).toThrowError(/contains invalid word/i);
expect(() => new bip39_1.EnglishMnemonic("riparato arrosto globulo singolo bozzolo roba pirolisi ultimato padrone munto leggero avanzato monetario guanto lorenzo latino inoltrare modulo")).toThrowError(/contains invalid word/i);
expect(() => new bip39_1.EnglishMnemonic("promessa mercurio spessore snodo trave risata mecenate vichingo ceto orecchino vissuto risultato canino scarso futile fune epilogo uovo inedito apatico folata egoismo rifugio coma")).toThrowError(/contains invalid word/i);
});
describe("toString", () => {
it("works", () => {
const original = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";
const mnemonic = new bip39_1.EnglishMnemonic(original);
expect(mnemonic.toString()).toEqual(original);
});
});
});
//# sourceMappingURL=bip39.spec.js.map

@@ -7,61 +7,28 @@ "use strict";

describe("HMAC", () => {
it("can perform HMAC(SHA1) according to Botan test vectors", () => {
// https://github.com/randombit/botan/blob/a5a260c/src/tests/data/mac/hmac.vec
{
const hmac = new hmac_1.Hmac(sha_1.Sha1, encoding_1.fromHex("0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B"));
hmac.update(encoding_1.fromHex("4869205468657265"));
expect(hmac.digest()).toEqual(encoding_1.fromHex("B617318655057264E28BC0B6FB378C8EF146BE00"));
}
{
const hmac = new hmac_1.Hmac(sha_1.Sha1, encoding_1.fromHex("0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C"));
hmac.update(encoding_1.fromHex("546573742057697468205472756E636174696F6E"));
expect(hmac.digest()).toEqual(encoding_1.fromHex("4C1A03424B55E07FE7F27BE1D58BB9324A9A5A04"));
}
{
const hmac = new hmac_1.Hmac(sha_1.Sha1, encoding_1.fromHex("4CA0EF38F1794B28A8F8EE110EE79D48CE13BE25"));
hmac.update(encoding_1.fromHex("54657374205573696E67204C6172676572205468616E20426C6F636B2D53697A65204B6579202D2048617368204B6579204669727374"));
expect(hmac.digest()).toEqual(encoding_1.fromHex("AA4AE5E15272D00E95705637CE8A3B55ED402112"));
}
{
const hmac = new hmac_1.Hmac(sha_1.Sha1, encoding_1.fromHex("4CA0EF38F1794B28A8F8EE110EE79D48CE13BE25"));
hmac.update(encoding_1.fromHex("54657374205573696E67204C6172676572205468616E20426C6F636B2D53697A65204B657920616E64204C6172676572205468616E204F6E6520426C6F636B2D53697A652044617461"));
expect(hmac.digest()).toEqual(encoding_1.fromHex("E8E99D0F45237D786D6BBAA7965C7808BBFF1A91"));
}
{
const hmac = new hmac_1.Hmac(sha_1.Sha1, encoding_1.fromHex("0102030405060708090A0B0C0D0E0F10111213141516171819"));
hmac.update(encoding_1.fromHex("CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD"));
expect(hmac.digest()).toEqual(encoding_1.fromHex("4C9007F4026250C6BC8414F9BF50C86C2D7235DA"));
}
{
const hmac = new hmac_1.Hmac(sha_1.Sha1, encoding_1.fromHex("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"));
hmac.update(encoding_1.fromHex("DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"));
expect(hmac.digest()).toEqual(encoding_1.fromHex("125D7342B9AC11CD91A39AF48AA17B4F63F175D3"));
}
});
it("can perform HMAC(SHA256) according to Botan test vectors", () => {
// https://github.com/randombit/botan/blob/a5a260c/src/tests/data/mac/hmac.vec#L60
{
const hmac = new hmac_1.Hmac(sha_1.Sha256, encoding_1.fromHex("0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20"));
hmac.update(encoding_1.fromHex("616263"));
expect(hmac.digest()).toEqual(encoding_1.fromHex("A21B1F5D4CF4F73A4DD939750F7A066A7F98CC131CB16A6692759021CFAB8181"));
const hmac = new hmac_1.Hmac(sha_1.Sha256, (0, encoding_1.fromHex)("0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20"));
hmac.update((0, encoding_1.fromHex)("616263"));
expect(hmac.digest()).toEqual((0, encoding_1.fromHex)("A21B1F5D4CF4F73A4DD939750F7A066A7F98CC131CB16A6692759021CFAB8181"));
}
{
const hmac = new hmac_1.Hmac(sha_1.Sha256, encoding_1.fromHex("4A656665"));
hmac.update(encoding_1.fromHex("7768617420646F2079612077616E7420666F72206E6F7468696E673F"));
expect(hmac.digest()).toEqual(encoding_1.fromHex("5BDCC146BF60754E6A042426089575C75A003F089D2739839DEC58B964EC3843"));
const hmac = new hmac_1.Hmac(sha_1.Sha256, (0, encoding_1.fromHex)("4A656665"));
hmac.update((0, encoding_1.fromHex)("7768617420646F2079612077616E7420666F72206E6F7468696E673F"));
expect(hmac.digest()).toEqual((0, encoding_1.fromHex)("5BDCC146BF60754E6A042426089575C75A003F089D2739839DEC58B964EC3843"));
}
{
const hmac = new hmac_1.Hmac(sha_1.Sha256, encoding_1.fromHex("0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20"));
hmac.update(encoding_1.fromHex("6162636462636465636465666465666765666768666768696768696A68696A6B696A6B6C6A6B6C6D6B6C6D6E6C6D6E6F6D6E6F706E6F70716162636462636465636465666465666765666768666768696768696A68696A6B696A6B6C6A6B6C6D6B6C6D6E6C6D6E6F6D6E6F706E6F7071"));
expect(hmac.digest()).toEqual(encoding_1.fromHex("470305FC7E40FE34D3EEB3E773D95AAB73ACF0FD060447A5EB4595BF33A9D1A3"));
const hmac = new hmac_1.Hmac(sha_1.Sha256, (0, encoding_1.fromHex)("0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F20"));
hmac.update((0, encoding_1.fromHex)("6162636462636465636465666465666765666768666768696768696A68696A6B696A6B6C6A6B6C6D6B6C6D6E6C6D6E6F6D6E6F706E6F70716162636462636465636465666465666765666768666768696768696A68696A6B696A6B6C6A6B6C6D6B6C6D6E6C6D6E6F6D6E6F706E6F7071"));
expect(hmac.digest()).toEqual((0, encoding_1.fromHex)("470305FC7E40FE34D3EEB3E773D95AAB73ACF0FD060447A5EB4595BF33A9D1A3"));
}
{
const hmac = new hmac_1.Hmac(sha_1.Sha256, encoding_1.fromHex("0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B"));
hmac.update(encoding_1.fromHex("4869205468657265"));
expect(hmac.digest()).toEqual(encoding_1.fromHex("198A607EB44BFBC69903A0F1CF2BBDC5BA0AA3F3D9AE3C1C7A3B1696A0B68CF7"));
const hmac = new hmac_1.Hmac(sha_1.Sha256, (0, encoding_1.fromHex)("0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B"));
hmac.update((0, encoding_1.fromHex)("4869205468657265"));
expect(hmac.digest()).toEqual((0, encoding_1.fromHex)("198A607EB44BFBC69903A0F1CF2BBDC5BA0AA3F3D9AE3C1C7A3B1696A0B68CF7"));
}
{
const hmac = new hmac_1.Hmac(sha_1.Sha256, encoding_1.fromHex("0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C"));
hmac.update(encoding_1.fromHex("546573742057697468205472756E636174696F6E"));
expect(hmac.digest()).toEqual(encoding_1.fromHex("7546AF01841FC09B1AB9C3749A5F1C17D4F589668A587B2700A9C97C1193CF42"));
const hmac = new hmac_1.Hmac(sha_1.Sha256, (0, encoding_1.fromHex)("0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C0C"));
hmac.update((0, encoding_1.fromHex)("546573742057697468205472756E636174696F6E"));
expect(hmac.digest()).toEqual((0, encoding_1.fromHex)("7546AF01841FC09B1AB9C3749A5F1C17D4F589668A587B2700A9C97C1193CF42"));
}

@@ -72,50 +39,51 @@ });

{
const hmac = new hmac_1.Hmac(sha_1.Sha512, encoding_1.fromHex("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"));
hmac.update(encoding_1.fromHex("4869205468657265"));
expect(hmac.digest()).toEqual(encoding_1.fromHex("87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854"));
const hmac = new hmac_1.Hmac(sha_1.Sha512, (0, encoding_1.fromHex)("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b"));
hmac.update((0, encoding_1.fromHex)("4869205468657265"));
expect(hmac.digest()).toEqual((0, encoding_1.fromHex)("87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854"));
}
{
const hmac = new hmac_1.Hmac(sha_1.Sha512, encoding_1.fromHex("4a656665"));
hmac.update(encoding_1.fromHex("7768617420646f2079612077616e7420666f72206e6f7468696e673f"));
expect(hmac.digest()).toEqual(encoding_1.fromHex("164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737"));
const hmac = new hmac_1.Hmac(sha_1.Sha512, (0, encoding_1.fromHex)("4a656665"));
hmac.update((0, encoding_1.fromHex)("7768617420646f2079612077616e7420666f72206e6f7468696e673f"));
expect(hmac.digest()).toEqual((0, encoding_1.fromHex)("164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737"));
}
{
const hmac = new hmac_1.Hmac(sha_1.Sha512, encoding_1.fromHex("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
hmac.update(encoding_1.fromHex("dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"));
expect(hmac.digest()).toEqual(encoding_1.fromHex("fa73b0089d56a284efb0f0756c890be9b1b5dbdd8ee81a3655f83e33b2279d39bf3e848279a722c806b485a47e67c807b946a337bee8942674278859e13292fb"));
const hmac = new hmac_1.Hmac(sha_1.Sha512, (0, encoding_1.fromHex)("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
hmac.update((0, encoding_1.fromHex)("dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"));
expect(hmac.digest()).toEqual((0, encoding_1.fromHex)("fa73b0089d56a284efb0f0756c890be9b1b5dbdd8ee81a3655f83e33b2279d39bf3e848279a722c806b485a47e67c807b946a337bee8942674278859e13292fb"));
}
{
const hmac = new hmac_1.Hmac(sha_1.Sha512, encoding_1.fromHex("0102030405060708090a0b0c0d0e0f10111213141516171819"));
hmac.update(encoding_1.fromHex("cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"));
expect(hmac.digest()).toEqual(encoding_1.fromHex("b0ba465637458c6990e5a8c5f61d4af7e576d97ff94b872de76f8050361ee3dba91ca5c11aa25eb4d679275cc5788063a5f19741120c4f2de2adebeb10a298dd"));
const hmac = new hmac_1.Hmac(sha_1.Sha512, (0, encoding_1.fromHex)("0102030405060708090a0b0c0d0e0f10111213141516171819"));
hmac.update((0, encoding_1.fromHex)("cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"));
expect(hmac.digest()).toEqual((0, encoding_1.fromHex)("b0ba465637458c6990e5a8c5f61d4af7e576d97ff94b872de76f8050361ee3dba91ca5c11aa25eb4d679275cc5788063a5f19741120c4f2de2adebeb10a298dd"));
}
{
const hmac = new hmac_1.Hmac(sha_1.Sha512, encoding_1.fromHex("0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c"));
hmac.update(encoding_1.fromHex("546573742057697468205472756e636174696f6e"));
expect(hmac.digest().slice(0, 16)).toEqual(encoding_1.fromHex("415fad6271580a531d4179bc891d87a6"));
const hmac = new hmac_1.Hmac(sha_1.Sha512, (0, encoding_1.fromHex)("0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c"));
hmac.update((0, encoding_1.fromHex)("546573742057697468205472756e636174696f6e"));
expect(hmac.digest().slice(0, 16)).toEqual((0, encoding_1.fromHex)("415fad6271580a531d4179bc891d87a6"));
}
{
const hmac = new hmac_1.Hmac(sha_1.Sha512, encoding_1.fromHex("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
hmac.update(encoding_1.fromHex("54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374"));
expect(hmac.digest()).toEqual(encoding_1.fromHex("80b24263c7c1a3ebb71493c1dd7be8b49b46d1f41b4aeec1121b013783f8f3526b56d037e05f2598bd0fd2215d6a1e5295e64f73f63f0aec8b915a985d786598"));
const hmac = new hmac_1.Hmac(sha_1.Sha512, (0, encoding_1.fromHex)("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
hmac.update((0, encoding_1.fromHex)("54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374"));
expect(hmac.digest()).toEqual((0, encoding_1.fromHex)("80b24263c7c1a3ebb71493c1dd7be8b49b46d1f41b4aeec1121b013783f8f3526b56d037e05f2598bd0fd2215d6a1e5295e64f73f63f0aec8b915a985d786598"));
}
{
const hmac = new hmac_1.Hmac(sha_1.Sha512, encoding_1.fromHex("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
hmac.update(encoding_1.fromHex("5468697320697320612074657374207573696e672061206c6172676572207468616e20626c6f636b2d73697a65206b657920616e642061206c6172676572207468616e20626c6f636b2d73697a6520646174612e20546865206b6579206e6565647320746f20626520686173686564206265666f7265206265696e6720757365642062792074686520484d414320616c676f726974686d2e"));
expect(hmac.digest()).toEqual(encoding_1.fromHex("e37b6a775dc87dbaa4dfa9f96e5e3ffddebd71f8867289865df5a32d20cdc944b6022cac3c4982b10d5eeb55c3e4de15134676fb6de0446065c97440fa8c6a58"));
const hmac = new hmac_1.Hmac(sha_1.Sha512, (0, encoding_1.fromHex)("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
hmac.update((0, encoding_1.fromHex)("5468697320697320612074657374207573696e672061206c6172676572207468616e20626c6f636b2d73697a65206b657920616e642061206c6172676572207468616e20626c6f636b2d73697a6520646174612e20546865206b6579206e6565647320746f20626520686173686564206265666f7265206265696e6720757365642062792074686520484d414320616c676f726974686d2e"));
expect(hmac.digest()).toEqual((0, encoding_1.fromHex)("e37b6a775dc87dbaa4dfa9f96e5e3ffddebd71f8867289865df5a32d20cdc944b6022cac3c4982b10d5eeb55c3e4de15134676fb6de0446065c97440fa8c6a58"));
}
});
it("can perform incremental hashing", () => {
const hmac = new hmac_1.Hmac(sha_1.Sha1, encoding_1.fromHex("0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B"));
// https://github.com/randombit/botan/blob/a5a260c/src/tests/data/mac/hmac.vec#L73-L75
const hmac = new hmac_1.Hmac(sha_1.Sha256, (0, encoding_1.fromHex)("0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B0B"));
// full message: 4869205468657265
hmac.update(encoding_1.fromHex(""));
hmac.update(encoding_1.fromHex("48"));
hmac.update(encoding_1.fromHex(""));
hmac.update(encoding_1.fromHex(""));
hmac.update(encoding_1.fromHex("69"));
hmac.update(encoding_1.fromHex("20"));
hmac.update(encoding_1.fromHex("5468"));
hmac.update(encoding_1.fromHex("657265"));
hmac.update(encoding_1.fromHex(""));
expect(hmac.digest()).toEqual(encoding_1.fromHex("B617318655057264E28BC0B6FB378C8EF146BE00"));
hmac.update((0, encoding_1.fromHex)(""));
hmac.update((0, encoding_1.fromHex)("48"));
hmac.update((0, encoding_1.fromHex)(""));
hmac.update((0, encoding_1.fromHex)(""));
hmac.update((0, encoding_1.fromHex)("69"));
hmac.update((0, encoding_1.fromHex)("20"));
hmac.update((0, encoding_1.fromHex)("5468"));
hmac.update((0, encoding_1.fromHex)("657265"));
hmac.update((0, encoding_1.fromHex)(""));
expect(hmac.digest()).toEqual((0, encoding_1.fromHex)("198A607EB44BFBC69903A0F1CF2BBDC5BA0AA3F3D9AE3C1C7A3B1696A0B68CF7"));
});

@@ -126,15 +94,15 @@ it("works with empty keys", () => {

{
const hmac = new hmac_1.Hmac(sha_1.Sha256, encoding_1.fromHex(""));
hmac.update(encoding_1.fromHex("7061756c"));
expect(hmac.digest()).toEqual(encoding_1.fromHex("50972b73add1dbbbe6884104d0f91efcef184e0aef6e485a075b3cab1f70e572"));
const hmac = new hmac_1.Hmac(sha_1.Sha256, (0, encoding_1.fromHex)(""));
hmac.update((0, encoding_1.fromHex)("7061756c"));
expect(hmac.digest()).toEqual((0, encoding_1.fromHex)("50972b73add1dbbbe6884104d0f91efcef184e0aef6e485a075b3cab1f70e572"));
}
{
const hmac = new hmac_1.Hmac(sha_1.Sha256, encoding_1.fromHex(""));
hmac.update(encoding_1.fromHex("70"));
expect(hmac.digest()).toEqual(encoding_1.fromHex("a1d75fa8dc0d1a84cf6df6f0e55cb52d89d44acb26e786c9329cf8dc8804a94e"));
const hmac = new hmac_1.Hmac(sha_1.Sha256, (0, encoding_1.fromHex)(""));
hmac.update((0, encoding_1.fromHex)("70"));
expect(hmac.digest()).toEqual((0, encoding_1.fromHex)("a1d75fa8dc0d1a84cf6df6f0e55cb52d89d44acb26e786c9329cf8dc8804a94e"));
}
{
const hmac = new hmac_1.Hmac(sha_1.Sha256, encoding_1.fromHex(""));
hmac.update(encoding_1.fromHex(""));
expect(hmac.digest()).toEqual(encoding_1.fromHex("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"));
const hmac = new hmac_1.Hmac(sha_1.Sha256, (0, encoding_1.fromHex)(""));
hmac.update((0, encoding_1.fromHex)(""));
expect(hmac.digest()).toEqual((0, encoding_1.fromHex)("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"));
}

@@ -141,0 +109,0 @@ });

@@ -1,7 +0,6 @@

export { Bip39 } from "./bip39";
export { EnglishMnemonic } from "./englishmnemonic";
export { Bip39, EnglishMnemonic } from "./bip39";
export { HashFunction } from "./hash";
export { Hmac } from "./hmac";
export { Keccak256, keccak256 } from "./keccak";
export { Xchacha20poly1305Ietf, xchacha20NonceLength, Argon2id, Argon2idOptions, isArgon2idOptions, Ed25519, Ed25519Keypair, } from "./libsodium";
export { Argon2id, Argon2idOptions, Ed25519, Ed25519Keypair, isArgon2idOptions, xchacha20NonceLength, Xchacha20poly1305Ietf, } from "./libsodium";
export { Random } from "./random";

@@ -11,3 +10,3 @@ export { Ripemd160, ripemd160 } from "./ripemd";

export { ExtendedSecp256k1Signature, Secp256k1Signature } from "./secp256k1signature";
export { Sha1, sha1, Sha256, sha256, Sha512, sha512 } from "./sha";
export { HdPath, pathToString, stringToPath, Slip10, Slip10Curve, Slip10RawIndex, Slip10Result, slip10CurveFromString, } from "./slip10";
export { Sha256, sha256, Sha512, sha512 } from "./sha";
export { HdPath, pathToString, Slip10, Slip10Curve, slip10CurveFromString, Slip10RawIndex, Slip10Result, stringToPath, } from "./slip10";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.slip10CurveFromString = exports.Slip10RawIndex = exports.Slip10Curve = exports.Slip10 = exports.stringToPath = exports.pathToString = exports.sha512 = exports.Sha512 = exports.sha256 = exports.Sha256 = exports.sha1 = exports.Sha1 = exports.Secp256k1Signature = exports.ExtendedSecp256k1Signature = exports.Secp256k1 = exports.ripemd160 = exports.Ripemd160 = exports.Random = exports.Ed25519Keypair = exports.Ed25519 = exports.isArgon2idOptions = exports.Argon2id = exports.xchacha20NonceLength = exports.Xchacha20poly1305Ietf = exports.keccak256 = exports.Keccak256 = exports.Hmac = exports.EnglishMnemonic = exports.Bip39 = void 0;
exports.stringToPath = exports.Slip10RawIndex = exports.slip10CurveFromString = exports.Slip10Curve = exports.Slip10 = exports.pathToString = exports.sha512 = exports.Sha512 = exports.sha256 = exports.Sha256 = exports.Secp256k1Signature = exports.ExtendedSecp256k1Signature = exports.Secp256k1 = exports.ripemd160 = exports.Ripemd160 = exports.Random = exports.Xchacha20poly1305Ietf = exports.xchacha20NonceLength = exports.isArgon2idOptions = exports.Ed25519Keypair = exports.Ed25519 = exports.Argon2id = exports.keccak256 = exports.Keccak256 = exports.Hmac = exports.EnglishMnemonic = exports.Bip39 = void 0;
var bip39_1 = require("./bip39");
Object.defineProperty(exports, "Bip39", { enumerable: true, get: function () { return bip39_1.Bip39; } });
var englishmnemonic_1 = require("./englishmnemonic");
Object.defineProperty(exports, "EnglishMnemonic", { enumerable: true, get: function () { return englishmnemonic_1.EnglishMnemonic; } });
Object.defineProperty(exports, "EnglishMnemonic", { enumerable: true, get: function () { return bip39_1.EnglishMnemonic; } });
var hmac_1 = require("./hmac");

@@ -14,8 +13,8 @@ Object.defineProperty(exports, "Hmac", { enumerable: true, get: function () { return hmac_1.Hmac; } });

var libsodium_1 = require("./libsodium");
Object.defineProperty(exports, "Xchacha20poly1305Ietf", { enumerable: true, get: function () { return libsodium_1.Xchacha20poly1305Ietf; } });
Object.defineProperty(exports, "xchacha20NonceLength", { enumerable: true, get: function () { return libsodium_1.xchacha20NonceLength; } });
Object.defineProperty(exports, "Argon2id", { enumerable: true, get: function () { return libsodium_1.Argon2id; } });
Object.defineProperty(exports, "isArgon2idOptions", { enumerable: true, get: function () { return libsodium_1.isArgon2idOptions; } });
Object.defineProperty(exports, "Ed25519", { enumerable: true, get: function () { return libsodium_1.Ed25519; } });
Object.defineProperty(exports, "Ed25519Keypair", { enumerable: true, get: function () { return libsodium_1.Ed25519Keypair; } });
Object.defineProperty(exports, "isArgon2idOptions", { enumerable: true, get: function () { return libsodium_1.isArgon2idOptions; } });
Object.defineProperty(exports, "xchacha20NonceLength", { enumerable: true, get: function () { return libsodium_1.xchacha20NonceLength; } });
Object.defineProperty(exports, "Xchacha20poly1305Ietf", { enumerable: true, get: function () { return libsodium_1.Xchacha20poly1305Ietf; } });
var random_1 = require("./random");

@@ -32,4 +31,2 @@ Object.defineProperty(exports, "Random", { enumerable: true, get: function () { return random_1.Random; } });

var sha_1 = require("./sha");
Object.defineProperty(exports, "Sha1", { enumerable: true, get: function () { return sha_1.Sha1; } });
Object.defineProperty(exports, "sha1", { enumerable: true, get: function () { return sha_1.sha1; } });
Object.defineProperty(exports, "Sha256", { enumerable: true, get: function () { return sha_1.Sha256; } });

@@ -41,7 +38,7 @@ Object.defineProperty(exports, "sha256", { enumerable: true, get: function () { return sha_1.sha256; } });

Object.defineProperty(exports, "pathToString", { enumerable: true, get: function () { return slip10_1.pathToString; } });
Object.defineProperty(exports, "stringToPath", { enumerable: true, get: function () { return slip10_1.stringToPath; } });
Object.defineProperty(exports, "Slip10", { enumerable: true, get: function () { return slip10_1.Slip10; } });
Object.defineProperty(exports, "Slip10Curve", { enumerable: true, get: function () { return slip10_1.Slip10Curve; } });
Object.defineProperty(exports, "slip10CurveFromString", { enumerable: true, get: function () { return slip10_1.slip10CurveFromString; } });
Object.defineProperty(exports, "Slip10RawIndex", { enumerable: true, get: function () { return slip10_1.Slip10RawIndex; } });
Object.defineProperty(exports, "slip10CurveFromString", { enumerable: true, get: function () { return slip10_1.slip10CurveFromString; } });
Object.defineProperty(exports, "stringToPath", { enumerable: true, get: function () { return slip10_1.stringToPath; } });
//# sourceMappingURL=index.js.map
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.keccak256 = exports.Keccak256 = void 0;
const js_sha3_1 = __importDefault(require("js-sha3"));
const sha3_1 = require("@noble/hashes/sha3");
const utils_1 = require("./utils");
class Keccak256 {
constructor(firstData) {
this.blockSize = 512 / 8;
this.impl = js_sha3_1.default.keccak256.create();
this.impl = sha3_1.keccak_256.create();
if (firstData) {

@@ -17,7 +15,7 @@ this.update(firstData);

update(data) {
this.impl.update(data);
this.impl.update((0, utils_1.toRealUint8Array)(data));
return this;
}
digest() {
return new Uint8Array(this.impl.digest());
return this.impl.digest();
}

@@ -24,0 +22,0 @@ }

@@ -16,7 +16,7 @@ "use strict";

const hash = new keccak_1.Keccak256(new Uint8Array([])).digest();
expect(encoding_1.toHex(hash)).toEqual("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470");
expect((0, encoding_1.toHex)(hash)).toEqual("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470");
}
{
const hash = new keccak_1.Keccak256().digest();
expect(encoding_1.toHex(hash)).toEqual("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470");
expect((0, encoding_1.toHex)(hash)).toEqual("c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470");
}

@@ -27,3 +27,3 @@ });

for (const { in: input, out: output } of keccak_json_1.default.keccak256) {
expect(new keccak_1.Keccak256(encoding_1.fromHex(input)).digest()).toEqual(encoding_1.fromHex(output));
expect(new keccak_1.Keccak256((0, encoding_1.fromHex)(input)).digest()).toEqual((0, encoding_1.fromHex)(output));
}

@@ -33,5 +33,5 @@ });

const { in: input, out: output } = keccak_json_1.default.keccak256[0];
expect(keccak_1.keccak256(encoding_1.fromHex(input))).toEqual(encoding_1.fromHex(output));
expect((0, keccak_1.keccak256)((0, encoding_1.fromHex)(input))).toEqual((0, encoding_1.fromHex)(output));
});
});
//# sourceMappingURL=keccak.spec.js.map

@@ -14,3 +14,3 @@ "use strict";

function isArgon2idOptions(thing) {
if (!utils_1.isNonNullObject(thing))
if (!(0, utils_1.isNonNullObject)(thing))
return false;

@@ -17,0 +17,0 @@ if (typeof thing.outputLength !== "number")

@@ -8,3 +8,3 @@ "use strict";

const data = random_1.Random.getBytes(5);
expect(utils_1.isUint8Array(data)).toEqual(true);
expect((0, utils_1.isUint8Array)(data)).toEqual(true);
});

@@ -11,0 +11,0 @@ it("creates random bytes", () => {

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ripemd160 = exports.Ripemd160 = void 0;
const ripemd160_1 = __importDefault(require("ripemd160"));
const ripemd160_1 = require("@noble/hashes/ripemd160");
const utils_1 = require("./utils");
class Ripemd160 {
constructor(firstData) {
this.blockSize = 512 / 8;
this.impl = new ripemd160_1.default();
this.impl = ripemd160_1.ripemd160.create();
if (firstData) {

@@ -17,7 +15,7 @@ this.update(firstData);

update(data) {
this.impl.update(Buffer.from(data));
this.impl.update((0, utils_1.toRealUint8Array)(data));
return this;
}
digest() {
return Uint8Array.from(this.impl.digest());
return this.impl.digest();
}

@@ -24,0 +22,0 @@ }

@@ -16,7 +16,7 @@ "use strict";

const hash = new ripemd_1.Ripemd160(new Uint8Array([])).digest();
expect(hash).toEqual(encoding_1.fromHex("9c1185a5c5e9fc54612808977ee8f548b2258d31"));
expect(hash).toEqual((0, encoding_1.fromHex)("9c1185a5c5e9fc54612808977ee8f548b2258d31"));
}
{
const hash = new ripemd_1.Ripemd160().digest();
expect(hash).toEqual(encoding_1.fromHex("9c1185a5c5e9fc54612808977ee8f548b2258d31"));
expect(hash).toEqual((0, encoding_1.fromHex)("9c1185a5c5e9fc54612808977ee8f548b2258d31"));
}

@@ -27,3 +27,3 @@ });

for (const { in: input, out: output } of ripemd_json_1.default.ripemd160) {
expect(new ripemd_1.Ripemd160(encoding_1.fromHex(input)).digest()).toEqual(encoding_1.fromHex(output));
expect(new ripemd_1.Ripemd160((0, encoding_1.fromHex)(input)).digest()).toEqual((0, encoding_1.fromHex)(output));
}

@@ -33,5 +33,5 @@ });

const { in: input, out: output } = ripemd_json_1.default.ripemd160[0];
expect(ripemd_1.ripemd160(encoding_1.fromHex(input))).toEqual(encoding_1.fromHex(output));
expect((0, ripemd_1.ripemd160)((0, encoding_1.fromHex)(input))).toEqual((0, encoding_1.fromHex)(output));
});
});
//# sourceMappingURL=ripemd.spec.js.map
import { ExtendedSecp256k1Signature, Secp256k1Signature } from "./secp256k1signature";
export interface Secp256k1Keypair {
/** A 32 byte private key */
readonly pubkey: Uint8Array;
/**
* A raw secp256k1 public key.
*
* The type itself does not give you any guarantee if this is
* compressed or uncompressed. If you are unsure where the data
* is coming from, use `Secp256k1.compressPubkey` or
* `Secp256k1.uncompressPubkey` (both idempotent) before processing it.
*/
readonly privkey: Uint8Array;
}
export declare class Secp256k1 {
/**
* Takes a 32 byte private key and returns a privkey/pubkey pair.
*
* The resulting pubkey is uncompressed. For the use in Cosmos it should
* be compressed first using `Secp256k1.compressPubkey`.
*/
static makeKeypair(privkey: Uint8Array): Promise<Secp256k1Keypair>;
/**
* Creates a signature that is
* - deterministic (RFC 6979)
* - lowS signature
* - DER encoded
*/
static createSignature(messageHash: Uint8Array, privkey: Uint8Array): Promise<ExtendedSecp256k1Signature>;
static verifySignature(signature: Secp256k1Signature, messageHash: Uint8Array, pubkey: Uint8Array): Promise<boolean>;
static recoverPubkey(signature: ExtendedSecp256k1Signature, messageHash: Uint8Array): Uint8Array;
/**
* Takes a compressed or uncompressed pubkey and return a compressed one.
*
* This function is idempotent.
*/
static compressPubkey(pubkey: Uint8Array): Uint8Array;
/**
* Takes a compressed or uncompressed pubkey and returns an uncompressed one.
*
* This function is idempotent.
*/
static uncompressPubkey(pubkey: Uint8Array): Uint8Array;
static trimRecoveryByte(signature: Uint8Array): Uint8Array;
}

@@ -14,2 +14,8 @@ "use strict";

class Secp256k1 {
/**
* Takes a 32 byte private key and returns a privkey/pubkey pair.
*
* The resulting pubkey is uncompressed. For the use in Cosmos it should
* be compressed first using `Secp256k1.compressPubkey`.
*/
static async makeKeypair(privkey) {

@@ -32,3 +38,3 @@ if (privkey.length !== 32) {

const out = {
privkey: encoding_1.fromHex(keypair.getPrivate("hex")),
privkey: (0, encoding_1.fromHex)(keypair.getPrivate("hex")),
// encodes uncompressed as

@@ -42,6 +48,8 @@ // - 1-byte prefix "04"

}
// Creates a signature that is
// - deterministic (RFC 6979)
// - lowS signature
// - DER encoded
/**
* Creates a signature that is
* - deterministic (RFC 6979)
* - lowS signature
* - DER encoded
*/
static async createSignature(messageHash, privkey) {

@@ -90,7 +98,12 @@ if (messageHash.length === 0) {

static recoverPubkey(signature, messageHash) {
const signatureForElliptic = { r: encoding_1.toHex(signature.r()), s: encoding_1.toHex(signature.s()) };
const signatureForElliptic = { r: (0, encoding_1.toHex)(signature.r()), s: (0, encoding_1.toHex)(signature.s()) };
const point = secp256k1.recoverPubKey(messageHash, signatureForElliptic, signature.recovery);
const keypair = secp256k1.keyFromPublic(point);
return encoding_1.fromHex(keypair.getPublic(false, "hex"));
return (0, encoding_1.fromHex)(keypair.getPublic(false, "hex"));
}
/**
* Takes a compressed or uncompressed pubkey and return a compressed one.
*
* This function is idempotent.
*/
static compressPubkey(pubkey) {

@@ -106,2 +119,17 @@ switch (pubkey.length) {

}
/**
* Takes a compressed or uncompressed pubkey and returns an uncompressed one.
*
* This function is idempotent.
*/
static uncompressPubkey(pubkey) {
switch (pubkey.length) {
case 33:
return Uint8Array.from(secp256k1.keyFromPublic(pubkey).getPublic(false, "array"));
case 65:
return pubkey;
default:
throw new Error("Invalid pubkey length");
}
}
static trimRecoveryByte(signature) {

@@ -108,0 +136,0 @@ switch (signature.length) {

@@ -23,34 +23,34 @@ "use strict";

// openssl ecparam -name secp256k1 -genkey | openssl ec -text -noout -conv_form uncompressed
const privkey = encoding_1.fromHex("5b1d5975dfdfb0027802265241d891e4af744cd39e78595658afaa7ac801d1d3");
const privkey = (0, encoding_1.fromHex)("5b1d5975dfdfb0027802265241d891e4af744cd39e78595658afaa7ac801d1d3");
const keypair = await secp256k1_1.Secp256k1.makeKeypair(privkey);
expect(keypair.pubkey).toEqual(encoding_1.fromHex("043e1113575cf01f9281381f626deccf76cdc85a320052297f7cae3548ea024d0b9fbec8a56d345a2984050be859c96471ef6aa4669ff31a659ce1d32db372f9b9"));
expect(keypair.pubkey).toEqual((0, encoding_1.fromHex)("043e1113575cf01f9281381f626deccf76cdc85a320052297f7cae3548ea024d0b9fbec8a56d345a2984050be859c96471ef6aa4669ff31a659ce1d32db372f9b9"));
});
it("preserves private key when making a keypair", async () => {
const privkey = encoding_1.fromHex("8c8bc2bc7954db5ef751e3e84b4e99bbe387a90d8019d8066c0e1e8bf33e713f");
const privkey = (0, encoding_1.fromHex)("8c8bc2bc7954db5ef751e3e84b4e99bbe387a90d8019d8066c0e1e8bf33e713f");
const keypair = await secp256k1_1.Secp256k1.makeKeypair(privkey);
expect(keypair.privkey).toEqual(encoding_1.fromHex("8c8bc2bc7954db5ef751e3e84b4e99bbe387a90d8019d8066c0e1e8bf33e713f"));
expect(keypair.privkey).toEqual((0, encoding_1.fromHex)("8c8bc2bc7954db5ef751e3e84b4e99bbe387a90d8019d8066c0e1e8bf33e713f"));
});
it("can load private keys", async () => {
expect(await secp256k1_1.Secp256k1.makeKeypair(encoding_1.fromHex("5eaf4344dab73d0caee1fd03607bb969074fb217f076896c2125f8607feab7b1"))).toBeTruthy();
expect(await secp256k1_1.Secp256k1.makeKeypair(encoding_1.fromHex("f7ac570ea2844e29e7f3b3c6a724ee1f47d3de8c2175a69abae94ae871573d0e"))).toBeTruthy();
expect(await secp256k1_1.Secp256k1.makeKeypair(encoding_1.fromHex("e4ade2a5232a7c6f37e7b854a774e25e6047ee7c6d63e8304ae04fa190bc1732"))).toBeTruthy();
expect(await secp256k1_1.Secp256k1.makeKeypair((0, encoding_1.fromHex)("5eaf4344dab73d0caee1fd03607bb969074fb217f076896c2125f8607feab7b1"))).toBeTruthy();
expect(await secp256k1_1.Secp256k1.makeKeypair((0, encoding_1.fromHex)("f7ac570ea2844e29e7f3b3c6a724ee1f47d3de8c2175a69abae94ae871573d0e"))).toBeTruthy();
expect(await secp256k1_1.Secp256k1.makeKeypair((0, encoding_1.fromHex)("e4ade2a5232a7c6f37e7b854a774e25e6047ee7c6d63e8304ae04fa190bc1732"))).toBeTruthy();
// smallest and largest allowed values: 1 and N-1 (from https://crypto.stackexchange.com/a/30273)
expect(await secp256k1_1.Secp256k1.makeKeypair(encoding_1.fromHex("0000000000000000000000000000000000000000000000000000000000000001"))).toBeTruthy();
expect(await secp256k1_1.Secp256k1.makeKeypair(encoding_1.fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364140"))).toBeTruthy();
expect(await secp256k1_1.Secp256k1.makeKeypair((0, encoding_1.fromHex)("0000000000000000000000000000000000000000000000000000000000000001"))).toBeTruthy();
expect(await secp256k1_1.Secp256k1.makeKeypair((0, encoding_1.fromHex)("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364140"))).toBeTruthy();
// too short and too long
await secp256k1_1.Secp256k1.makeKeypair(encoding_1.fromHex("e4ade2a5232a7c6f37e7b854a774e25e6047ee7c6d63e8304ae04fa190bc17"))
await secp256k1_1.Secp256k1.makeKeypair((0, encoding_1.fromHex)("e4ade2a5232a7c6f37e7b854a774e25e6047ee7c6d63e8304ae04fa190bc17"))
.then(() => fail("promise must be rejected"))
.catch((error) => expect(error.message).toContain("not a valid secp256k1 private key"));
await secp256k1_1.Secp256k1.makeKeypair(encoding_1.fromHex("e4ade2a5232a7c6f37e7b854a774e25e6047ee7c6d63e8304ae04fa190bc1732aa"))
await secp256k1_1.Secp256k1.makeKeypair((0, encoding_1.fromHex)("e4ade2a5232a7c6f37e7b854a774e25e6047ee7c6d63e8304ae04fa190bc1732aa"))
.then(() => fail("promise must be rejected"))
.catch((error) => expect(error.message).toContain("not a valid secp256k1 private key"));
// value out of range (too small)
await secp256k1_1.Secp256k1.makeKeypair(encoding_1.fromHex("0000000000000000000000000000000000000000000000000000000000000000"))
await secp256k1_1.Secp256k1.makeKeypair((0, encoding_1.fromHex)("0000000000000000000000000000000000000000000000000000000000000000"))
.then(() => fail("promise must be rejected"))
.catch((error) => expect(error.message).toContain("not a valid secp256k1 private key"));
// value out of range (>= n)
await secp256k1_1.Secp256k1.makeKeypair(encoding_1.fromHex("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"))
await secp256k1_1.Secp256k1.makeKeypair((0, encoding_1.fromHex)("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"))
.then(() => fail("promise must be rejected"))
.catch((error) => expect(error.message).toContain("not a valid secp256k1 private key"));
await secp256k1_1.Secp256k1.makeKeypair(encoding_1.fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"))
await secp256k1_1.Secp256k1.makeKeypair((0, encoding_1.fromHex)("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"))
.then(() => fail("promise must be rejected"))

@@ -60,3 +60,3 @@ .catch((error) => expect(error.message).toContain("not a valid secp256k1 private key"));

it("creates signatures", async () => {
const privkey = encoding_1.fromHex("43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0b9");
const privkey = (0, encoding_1.fromHex)("43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0b9");
const keypair = await secp256k1_1.Secp256k1.makeKeypair(privkey);

@@ -70,3 +70,3 @@ const messageHash = new Uint8Array([0x11, 0x22]);

it("creates signatures deterministically", async () => {
const privkey = encoding_1.fromHex("43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0b9");
const privkey = (0, encoding_1.fromHex)("43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0b9");
const keypair = await secp256k1_1.Secp256k1.makeKeypair(privkey);

@@ -79,3 +79,3 @@ const messageHash = new Uint8Array([0x11, 0x22]);

it("throws for empty message hash in signing", async () => {
const privkey = encoding_1.fromHex("43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0b9");
const privkey = (0, encoding_1.fromHex)("43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0b9");
const keypair = await secp256k1_1.Secp256k1.makeKeypair(privkey);

@@ -88,5 +88,5 @@ const messageHash = new Uint8Array([]);

it("throws for message hash longer than 32 bytes in signing", async () => {
const privkey = encoding_1.fromHex("43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0b9");
const privkey = (0, encoding_1.fromHex)("43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0b9");
const keypair = await secp256k1_1.Secp256k1.makeKeypair(privkey);
const messageHash = encoding_1.fromHex("11223344556677889900aabbccddeeff11223344556677889900aabbccddeeff11");
const messageHash = (0, encoding_1.fromHex)("11223344556677889900aabbccddeeff11223344556677889900aabbccddeeff11");
await secp256k1_1.Secp256k1.createSignature(messageHash, keypair.privkey)

@@ -97,3 +97,3 @@ .then(() => fail("must not resolve"))

it("verifies signatures", async () => {
const privkey = encoding_1.fromHex("43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0b9");
const privkey = (0, encoding_1.fromHex)("43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0b9");
const keypair = await secp256k1_1.Secp256k1.makeKeypair(privkey);

@@ -121,3 +121,3 @@ const messageHash = new Uint8Array([0x11, 0x22]);

// wrong pubkey
const otherPrivkey = encoding_1.fromHex("91099374790843e29552c3cfa5e9286d6c77e00a2c109aaf3d0a307081314a09");
const otherPrivkey = (0, encoding_1.fromHex)("91099374790843e29552c3cfa5e9286d6c77e00a2c109aaf3d0a307081314a09");
const wrongPubkey = (await secp256k1_1.Secp256k1.makeKeypair(otherPrivkey)).pubkey;

@@ -129,4 +129,4 @@ const ok = await secp256k1_1.Secp256k1.verifySignature(signature, messageHash, wrongPubkey);

it("throws for empty message hash in verification", async () => {
const dummySignature = secp256k1signature_1.Secp256k1Signature.fromDer(encoding_1.fromHex("304602210083de9be443bcf480892b8c8ca1d5ee65c79a315642c3f7b5305aff3065fda2780221009747932122b93cec42cad8ee4630a8f6cbe127578b8c495b4ab927275f657658"));
const keypair = await secp256k1_1.Secp256k1.makeKeypair(encoding_1.fromHex("43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0b9"));
const dummySignature = secp256k1signature_1.Secp256k1Signature.fromDer((0, encoding_1.fromHex)("304602210083de9be443bcf480892b8c8ca1d5ee65c79a315642c3f7b5305aff3065fda2780221009747932122b93cec42cad8ee4630a8f6cbe127578b8c495b4ab927275f657658"));
const keypair = await secp256k1_1.Secp256k1.makeKeypair((0, encoding_1.fromHex)("43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0b9"));
const messageHash = new Uint8Array([]);

@@ -138,5 +138,5 @@ await secp256k1_1.Secp256k1.verifySignature(dummySignature, messageHash, keypair.pubkey)

it("throws for message hash longer than 32 bytes in verification", async () => {
const dummySignature = secp256k1signature_1.Secp256k1Signature.fromDer(encoding_1.fromHex("304602210083de9be443bcf480892b8c8ca1d5ee65c79a315642c3f7b5305aff3065fda2780221009747932122b93cec42cad8ee4630a8f6cbe127578b8c495b4ab927275f657658"));
const keypair = await secp256k1_1.Secp256k1.makeKeypair(encoding_1.fromHex("43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0b9"));
const messageHash = encoding_1.fromHex("11223344556677889900aabbccddeeff11223344556677889900aabbccddeeff11");
const dummySignature = secp256k1signature_1.Secp256k1Signature.fromDer((0, encoding_1.fromHex)("304602210083de9be443bcf480892b8c8ca1d5ee65c79a315642c3f7b5305aff3065fda2780221009747932122b93cec42cad8ee4630a8f6cbe127578b8c495b4ab927275f657658"));
const keypair = await secp256k1_1.Secp256k1.makeKeypair((0, encoding_1.fromHex)("43a9c17ccbb0e767ea29ce1f10813afde5f1e0a7a504e89b4d2cc2b952b8e0b9"));
const messageHash = (0, encoding_1.fromHex)("11223344556677889900aabbccddeeff11223344556677889900aabbccddeeff11");
await secp256k1_1.Secp256k1.verifySignature(dummySignature, messageHash, keypair.privkey)

@@ -150,100 +150,100 @@ .then(() => fail("must not resolve"))

{
message: encoding_1.fromHex("5c868fedb8026979ebd26f1ba07c27eedf4ff6d10443505a96ecaf21ba8c4f0937b3cd23ffdc3dd429d4cd1905fb8dbcceeff1350020e18b58d2ba70887baa3a9b783ad30d3fbf210331cdd7df8d77defa398cdacdfc2e359c7ba4cae46bb74401deb417f8b912a1aa966aeeba9c39c7dd22479ae2b30719dca2f2206c5eb4b7"),
privkey: encoding_1.fromHex("21142a7e90031ea750c9fa1ba1beae16782386be438133bd43195826ae2e25f0"),
signature: encoding_1.fromHex("30440220207082eb2c3dfa0b454e0906051270ba4074ac93760ba9e7110cd94714751111022051eb0dbbc9920e72146fb564f99d039802bf6ef2561446eb126ef364d21ee9c4"),
message: (0, encoding_1.fromHex)("5c868fedb8026979ebd26f1ba07c27eedf4ff6d10443505a96ecaf21ba8c4f0937b3cd23ffdc3dd429d4cd1905fb8dbcceeff1350020e18b58d2ba70887baa3a9b783ad30d3fbf210331cdd7df8d77defa398cdacdfc2e359c7ba4cae46bb74401deb417f8b912a1aa966aeeba9c39c7dd22479ae2b30719dca2f2206c5eb4b7"),
privkey: (0, encoding_1.fromHex)("21142a7e90031ea750c9fa1ba1beae16782386be438133bd43195826ae2e25f0"),
signature: (0, encoding_1.fromHex)("30440220207082eb2c3dfa0b454e0906051270ba4074ac93760ba9e7110cd94714751111022051eb0dbbc9920e72146fb564f99d039802bf6ef2561446eb126ef364d21ee9c4"),
},
{
message: encoding_1.fromHex("17cd4a74d724d55355b6fb2b0759ca095298e3fd1856b87ca1cb2df5409058022736d21be071d820b16dfc441be97fbcea5df787edc886e759475469e2128b22f26b82ca993be6695ab190e673285d561d3b6d42fcc1edd6d12db12dcda0823e9d6079e7bc5ff54cd452dad308d52a15ce9c7edd6ef3dad6a27becd8e001e80f"),
privkey: encoding_1.fromHex("824282b6069fe3df857ce37204df4312c35750ee7a0f5e5fd8181666d5e46fb2"),
signature: encoding_1.fromHex("30440220626d61b7be1488b563e8a85bfb623b2331903964b5c0476c9f9ad29144f076fe02202002a2c0ab5e48626bf761cf677dfeede9c7309d2436d4b8c2b89f21ee2ebc6a"),
message: (0, encoding_1.fromHex)("17cd4a74d724d55355b6fb2b0759ca095298e3fd1856b87ca1cb2df5409058022736d21be071d820b16dfc441be97fbcea5df787edc886e759475469e2128b22f26b82ca993be6695ab190e673285d561d3b6d42fcc1edd6d12db12dcda0823e9d6079e7bc5ff54cd452dad308d52a15ce9c7edd6ef3dad6a27becd8e001e80f"),
privkey: (0, encoding_1.fromHex)("824282b6069fe3df857ce37204df4312c35750ee7a0f5e5fd8181666d5e46fb2"),
signature: (0, encoding_1.fromHex)("30440220626d61b7be1488b563e8a85bfb623b2331903964b5c0476c9f9ad29144f076fe02202002a2c0ab5e48626bf761cf677dfeede9c7309d2436d4b8c2b89f21ee2ebc6a"),
},
{
message: encoding_1.fromHex("db0d31717b04802adbbae1997487da8773440923c09b869e12a57c36dda34af11b8897f266cd81c02a762c6b74ea6aaf45aaa3c52867eb8f270f5092a36b498f88b65b2ebda24afe675da6f25379d1e194d093e7a2f66e450568dbdffebff97c4597a00c96a5be9ba26deefcca8761c1354429622c8db269d6a0ec0cc7a8585c"),
privkey: encoding_1.fromHex("5c0da42cec87a6b7a173514965343c30013386c0fe9b39203ed7af43ea425944"),
signature: encoding_1.fromHex("304602210083de9be443bcf480892b8c8ca1d5ee65c79a315642c3f7b5305aff3065fda2780221009747932122b93cec42cad8ee4630a8f6cbe127578b8c495b4ab927275f657658"),
message: (0, encoding_1.fromHex)("db0d31717b04802adbbae1997487da8773440923c09b869e12a57c36dda34af11b8897f266cd81c02a762c6b74ea6aaf45aaa3c52867eb8f270f5092a36b498f88b65b2ebda24afe675da6f25379d1e194d093e7a2f66e450568dbdffebff97c4597a00c96a5be9ba26deefcca8761c1354429622c8db269d6a0ec0cc7a8585c"),
privkey: (0, encoding_1.fromHex)("5c0da42cec87a6b7a173514965343c30013386c0fe9b39203ed7af43ea425944"),
signature: (0, encoding_1.fromHex)("304602210083de9be443bcf480892b8c8ca1d5ee65c79a315642c3f7b5305aff3065fda2780221009747932122b93cec42cad8ee4630a8f6cbe127578b8c495b4ab927275f657658"),
},
{
message: encoding_1.fromHex("47c9deddfd8c841a63a99be96e972e40fa035ae10d929babfc86c437b9d5d495577a45b7f8a35ce3f880e7d8ae8cd8eb685cf41f0506e68046ccf5559232c674abb9c3683829dcc8002683c4f4ca3a29a7bfde20d96dd0f1a0ead847dea18f297f220f94932536ca4deacedc2c6701c3ee50e28e358dcc54cdbf69daf0eb87f6"),
privkey: encoding_1.fromHex("ab30a326599165b48c65ab8d3c77d312d7b2ea4853f721e18cc278628a866980"),
signature: encoding_1.fromHex("30440220723da69da81c8f6b081a9a728b9bba785d2067e0ed769675f8a7563d22ed8a1602203a993793cf39b96b3cd625df0e06f206e17579cd8ebcb7e704174c3d94dba684"),
message: (0, encoding_1.fromHex)("47c9deddfd8c841a63a99be96e972e40fa035ae10d929babfc86c437b9d5d495577a45b7f8a35ce3f880e7d8ae8cd8eb685cf41f0506e68046ccf5559232c674abb9c3683829dcc8002683c4f4ca3a29a7bfde20d96dd0f1a0ead847dea18f297f220f94932536ca4deacedc2c6701c3ee50e28e358dcc54cdbf69daf0eb87f6"),
privkey: (0, encoding_1.fromHex)("ab30a326599165b48c65ab8d3c77d312d7b2ea4853f721e18cc278628a866980"),
signature: (0, encoding_1.fromHex)("30440220723da69da81c8f6b081a9a728b9bba785d2067e0ed769675f8a7563d22ed8a1602203a993793cf39b96b3cd625df0e06f206e17579cd8ebcb7e704174c3d94dba684"),
},
{
message: encoding_1.fromHex("f15433188c2bbc93b2150bb2f34d36ba8ae49f8f7e4e81aed651c8fb2022b2a7e851c4dbbbc21c14e27380316bfdebb0a049246349537dba687581c1344e40f75afd2735bb21ea074861de6801d28b22e8beb76fdd25598812b2061ca3fba229daf59a4ab416704543b02e16b8136c22acc7e197748ae19b5cbbc160fdc3a8cd"),
privkey: encoding_1.fromHex("1560b9fa5229f623a9c556132da4fc0e58633f39ce6421d25b5a6cde4ad7e019"),
signature: encoding_1.fromHex("304502200e0c5228e6783bee4d0406f4f7b7d79f705f0dbb55126966f79e631bd8b23079022100faae33aec5b0fafd3413c14bfdef9c7c9ac6abd06c923c48ab136a2c56826118"),
message: (0, encoding_1.fromHex)("f15433188c2bbc93b2150bb2f34d36ba8ae49f8f7e4e81aed651c8fb2022b2a7e851c4dbbbc21c14e27380316bfdebb0a049246349537dba687581c1344e40f75afd2735bb21ea074861de6801d28b22e8beb76fdd25598812b2061ca3fba229daf59a4ab416704543b02e16b8136c22acc7e197748ae19b5cbbc160fdc3a8cd"),
privkey: (0, encoding_1.fromHex)("1560b9fa5229f623a9c556132da4fc0e58633f39ce6421d25b5a6cde4ad7e019"),
signature: (0, encoding_1.fromHex)("304502200e0c5228e6783bee4d0406f4f7b7d79f705f0dbb55126966f79e631bd8b23079022100faae33aec5b0fafd3413c14bfdef9c7c9ac6abd06c923c48ab136a2c56826118"),
},
{
message: encoding_1.fromHex("1bc796124b87793b7f7fdd53b896f8f0d0f2d2be36d1944e3c2a0ac5c6b2839f59a4b4fad200f8035ec98630c51ef0d40863a5ddd69b703d73f06b4afae8ad1a88e19b1b26e8c10b7bff953c05eccc82fd771b220910165f3a906b7c931683e431998d1fd06c32dd11b4f872bf980d547942f22124c7e50c9523321aee23a36d"),
privkey: encoding_1.fromHex("42f7d48e1c90f3d20252713f7c7c6ce8492c2b99bcef198927de334cda6bad00"),
signature: encoding_1.fromHex("3046022100b9d3962edadc893f8eeff379f136c7b8fc6ea824a5afc6cbda7e3cb4c7a1e860022100bb1c1f901cf450edfdce20686352bb0cf0a643301123140ec87c92480d7f9d6a"),
message: (0, encoding_1.fromHex)("1bc796124b87793b7f7fdd53b896f8f0d0f2d2be36d1944e3c2a0ac5c6b2839f59a4b4fad200f8035ec98630c51ef0d40863a5ddd69b703d73f06b4afae8ad1a88e19b1b26e8c10b7bff953c05eccc82fd771b220910165f3a906b7c931683e431998d1fd06c32dd11b4f872bf980d547942f22124c7e50c9523321aee23a36d"),
privkey: (0, encoding_1.fromHex)("42f7d48e1c90f3d20252713f7c7c6ce8492c2b99bcef198927de334cda6bad00"),
signature: (0, encoding_1.fromHex)("3046022100b9d3962edadc893f8eeff379f136c7b8fc6ea824a5afc6cbda7e3cb4c7a1e860022100bb1c1f901cf450edfdce20686352bb0cf0a643301123140ec87c92480d7f9d6a"),
},
{
message: encoding_1.fromHex("18e55ac264031da435b613fc9dc6c4aafc49aae8ddf6f220d523415896ff915fae5c5b2e6aed61d88e5721823f089c46173afc5d9b47fd917834c85284f62dda6ed2d7a6ff10eb553b9312b05dad7decf7f73b69479c02f14ea0a2aa9e05ec07396cd37c28795c90e590631137102315635d702278e352aa41d0826adadff5e1"),
privkey: encoding_1.fromHex("6fe5b986c18da5d4fbcea6f602f469ac039085247ccb97b6292992363ea1d21c"),
signature: encoding_1.fromHex("30460221009369ab86afae5e22ed5f4012964804d2a19c36b8b58cf2855205b1cfcc937422022100a27dfc38d899b78edcf38a1b2b53578e72270b083d7d69424c4b4a7d25d39f4d"),
message: (0, encoding_1.fromHex)("18e55ac264031da435b613fc9dc6c4aafc49aae8ddf6f220d523415896ff915fae5c5b2e6aed61d88e5721823f089c46173afc5d9b47fd917834c85284f62dda6ed2d7a6ff10eb553b9312b05dad7decf7f73b69479c02f14ea0a2aa9e05ec07396cd37c28795c90e590631137102315635d702278e352aa41d0826adadff5e1"),
privkey: (0, encoding_1.fromHex)("6fe5b986c18da5d4fbcea6f602f469ac039085247ccb97b6292992363ea1d21c"),
signature: (0, encoding_1.fromHex)("30460221009369ab86afae5e22ed5f4012964804d2a19c36b8b58cf2855205b1cfcc937422022100a27dfc38d899b78edcf38a1b2b53578e72270b083d7d69424c4b4a7d25d39f4d"),
},
{
message: encoding_1.fromHex("a5290666c97294d090f8da898e555cbd33990579e5e95498444bfb318b4aa1643e0d4348425e21c7c6f99f9955f3048f56c22b68c4a516af5c90ed5268acc9c5a20fec0200c2a282a90e20d3c46d4ecdda18ba18b803b19263de2b79238da921707a0864799cdee9f02913b40681c02c6923070688844b58fe415b7d71ea6845"),
privkey: encoding_1.fromHex("fbf02ff086b215d057130a509346b64eb63bec0e38db692e07ad24c6ca8fe210"),
signature: encoding_1.fromHex("3045022100c5e439cef76b28dc0fe9d260763bec05b5e795ac8d90b25d9fccbc1918bc32f302201b06144e6b191224d5eda822a5b3b2026af6aa7f25a9061c9e81c312728aa94a"),
message: (0, encoding_1.fromHex)("a5290666c97294d090f8da898e555cbd33990579e5e95498444bfb318b4aa1643e0d4348425e21c7c6f99f9955f3048f56c22b68c4a516af5c90ed5268acc9c5a20fec0200c2a282a90e20d3c46d4ecdda18ba18b803b19263de2b79238da921707a0864799cdee9f02913b40681c02c6923070688844b58fe415b7d71ea6845"),
privkey: (0, encoding_1.fromHex)("fbf02ff086b215d057130a509346b64eb63bec0e38db692e07ad24c6ca8fe210"),
signature: (0, encoding_1.fromHex)("3045022100c5e439cef76b28dc0fe9d260763bec05b5e795ac8d90b25d9fccbc1918bc32f302201b06144e6b191224d5eda822a5b3b2026af6aa7f25a9061c9e81c312728aa94a"),
},
{
message: encoding_1.fromHex("13ad0600229c2a66b2f11617f69c7210ad044c49265dc98ec3c64f56e56a083234d277d404e2c40523c414ad23af5cc2f91a47fe59e7ca572f7fe1d3d3cfceaedadac4396749a292a38e92727273272335f12b2acea21cf069682e67d7e7d7a31ab5bb8e472298a9451aeae6f160f36e6623c9b632b9c93371a002818addc243"),
privkey: encoding_1.fromHex("474a7dc7f5033b6bf5e3027254cd0dbd956f16f61874b2992839a867f607d0dd"),
signature: encoding_1.fromHex("3045022100ee8615a5fab6fc674e6d3d9cde8da2b18dece076ae94d96662e16109db12d72002203171705cdab2b3d34c58e556c80358c105807e98243f5754b70b771071308b94"),
message: (0, encoding_1.fromHex)("13ad0600229c2a66b2f11617f69c7210ad044c49265dc98ec3c64f56e56a083234d277d404e2c40523c414ad23af5cc2f91a47fe59e7ca572f7fe1d3d3cfceaedadac4396749a292a38e92727273272335f12b2acea21cf069682e67d7e7d7a31ab5bb8e472298a9451aeae6f160f36e6623c9b632b9c93371a002818addc243"),
privkey: (0, encoding_1.fromHex)("474a7dc7f5033b6bf5e3027254cd0dbd956f16f61874b2992839a867f607d0dd"),
signature: (0, encoding_1.fromHex)("3045022100ee8615a5fab6fc674e6d3d9cde8da2b18dece076ae94d96662e16109db12d72002203171705cdab2b3d34c58e556c80358c105807e98243f5754b70b771071308b94"),
},
{
message: encoding_1.fromHex("51ad843da5eafc177d49a50a82609555e52773c5dfa14d7c02db5879c11a6b6e2e0860df38452dc579d763f91a83ade23b73f4fcbd703f35dd6ecfbb4c9578d5b604ed809c8633e6ac5679a5f742ce94fea3b97b5ba8a29ea28101a7b35f9eaa894dda54e3431f2464d18faf8342b7c59dfe0598c0ab29a14622a08eea70126b"),
privkey: encoding_1.fromHex("e8a2939a46e6bb7e706e419c0101d39f0494935b17fe3ca907b2ea3558d6ab3a"),
signature: encoding_1.fromHex("3046022100f753c447161aa3a58e5deeca31797f21484fb0ec3a7fe6e464ab1914896f253b02210099640fbcce1f25fd66744b046e0dfd57fa23070555f438af6c5e5828d47e9fa7"),
message: (0, encoding_1.fromHex)("51ad843da5eafc177d49a50a82609555e52773c5dfa14d7c02db5879c11a6b6e2e0860df38452dc579d763f91a83ade23b73f4fcbd703f35dd6ecfbb4c9578d5b604ed809c8633e6ac5679a5f742ce94fea3b97b5ba8a29ea28101a7b35f9eaa894dda54e3431f2464d18faf8342b7c59dfe0598c0ab29a14622a08eea70126b"),
privkey: (0, encoding_1.fromHex)("e8a2939a46e6bb7e706e419c0101d39f0494935b17fe3ca907b2ea3558d6ab3a"),
signature: (0, encoding_1.fromHex)("3046022100f753c447161aa3a58e5deeca31797f21484fb0ec3a7fe6e464ab1914896f253b02210099640fbcce1f25fd66744b046e0dfd57fa23070555f438af6c5e5828d47e9fa7"),
},
{
message: encoding_1.fromHex("678b505467d55ce01aec23fd4851957137c3a1de3ff2c673ec95a577aa9fb011b4b4a8eb7a0e6f391d4236a35b7e769692ace5851d7c53700e180fa522d3d37dbaa496163f3de6d96391e38ff83271e621f2458729ff74de462cdce6b3029f308d4eb8aef036357b9de06d68558e0388a6e88af91340c875050b8c91c4e26fc8"),
privkey: encoding_1.fromHex("08ce8f7118eda55b008f6eb3281a445a3ddbc5209d5ac16c09dbf40fe4bbc22c"),
signature: encoding_1.fromHex("30440220439fd0423bde36a1616a6fa4343bb7e07a6b3f6dc629aa8c93c91831055e476c022020998a26ae4b96ef36d48d83e8af0288f0bbc2db5ca5c8271a42f3fdc478fcb2"),
message: (0, encoding_1.fromHex)("678b505467d55ce01aec23fd4851957137c3a1de3ff2c673ec95a577aa9fb011b4b4a8eb7a0e6f391d4236a35b7e769692ace5851d7c53700e180fa522d3d37dbaa496163f3de6d96391e38ff83271e621f2458729ff74de462cdce6b3029f308d4eb8aef036357b9de06d68558e0388a6e88af91340c875050b8c91c4e26fc8"),
privkey: (0, encoding_1.fromHex)("08ce8f7118eda55b008f6eb3281a445a3ddbc5209d5ac16c09dbf40fe4bbc22c"),
signature: (0, encoding_1.fromHex)("30440220439fd0423bde36a1616a6fa4343bb7e07a6b3f6dc629aa8c93c91831055e476c022020998a26ae4b96ef36d48d83e8af0288f0bbc2db5ca5c8271a42f3fdc478fcb2"),
},
{
message: encoding_1.fromHex("9bf457159f0d44b78d0e151ee53c41cecd98fb4e4129fcda8cc84a758636f84dcad9032f3ec422219d8a7ec61ea89f45d19cab3c3d451de1a634e3d2532231bc03031973d7150cf8e83d8b6a34f25fc136446878e3851b780abdca069c8e981b3ea3f1bf1ff6e47a03f97aed64c1cc90dd00389fa21bb973f142af5e8ceccef4"),
privkey: encoding_1.fromHex("820be5c5e14e802300ca024fce318910f00470f6c3eabb12e7f3fac9383cf247"),
signature: encoding_1.fromHex("304502204ce72a83cf1d148db4d1e46e2f773c677f72933c40d7100b9192750a1c8222a80221009d5fbd67ce89ba8c79df9dc3b42922026a8498921c2bdb4ea8f36496d88c2cfb"),
message: (0, encoding_1.fromHex)("9bf457159f0d44b78d0e151ee53c41cecd98fb4e4129fcda8cc84a758636f84dcad9032f3ec422219d8a7ec61ea89f45d19cab3c3d451de1a634e3d2532231bc03031973d7150cf8e83d8b6a34f25fc136446878e3851b780abdca069c8e981b3ea3f1bf1ff6e47a03f97aed64c1cc90dd00389fa21bb973f142af5e8ceccef4"),
privkey: (0, encoding_1.fromHex)("820be5c5e14e802300ca024fce318910f00470f6c3eabb12e7f3fac9383cf247"),
signature: (0, encoding_1.fromHex)("304502204ce72a83cf1d148db4d1e46e2f773c677f72933c40d7100b9192750a1c8222a80221009d5fbd67ce89ba8c79df9dc3b42922026a8498921c2bdb4ea8f36496d88c2cfb"),
},
{
message: encoding_1.fromHex("2469172b7a046e6112dfe365590dfddb7c045cccd4ab353edc3076091aad1c780a9a73ff93f3dbf9e2189c5d1fdd6f6167d0ae8cc0f53dc8950e60dd0410e23589999d4ce4fa49e268774defd4edce01c05b205014b63591a041745bfffc6ae4d72d3add353e49478106653cc735b07b0fe665c42d0e6766e525bb9718264c87"),
privkey: encoding_1.fromHex("d92d6170e63bc33647e6dcdf1981771ecd57e11d47d73138696fbf49a430c3ab"),
signature: encoding_1.fromHex("304502201f1e1fb673e9a7dee09961c6824b473189904deb4f0d8e28da51f77f4de2efe6022100ae8df1fcdb226fac8b46e494720e45f6d9a5350174faaf22e47b6329ee6c5e1b"),
message: (0, encoding_1.fromHex)("2469172b7a046e6112dfe365590dfddb7c045cccd4ab353edc3076091aad1c780a9a73ff93f3dbf9e2189c5d1fdd6f6167d0ae8cc0f53dc8950e60dd0410e23589999d4ce4fa49e268774defd4edce01c05b205014b63591a041745bfffc6ae4d72d3add353e49478106653cc735b07b0fe665c42d0e6766e525bb9718264c87"),
privkey: (0, encoding_1.fromHex)("d92d6170e63bc33647e6dcdf1981771ecd57e11d47d73138696fbf49a430c3ab"),
signature: (0, encoding_1.fromHex)("304502201f1e1fb673e9a7dee09961c6824b473189904deb4f0d8e28da51f77f4de2efe6022100ae8df1fcdb226fac8b46e494720e45f6d9a5350174faaf22e47b6329ee6c5e1b"),
},
{
message: encoding_1.fromHex("6f8983e74f304c3657cffde0682b42699cb2c3475b925058ff37292c40a0aa296690ad129730339ac60cf784225b2fd3db58297c8ce5889df7a48d3e74a363ae4135e8a234cab53ca4c11c031d561a6cf7dd47b925ed5bc4c2794ba7b74a868b0c3da31ff1e4540d0768612192a236d86f74fb8c73f375b71c62f1648c0e6126"),
privkey: encoding_1.fromHex("a70eb435feaeb6ccda7d3ebd3c4ae40b60643bc933f37ad1aca41dd086e8ae50"),
signature: encoding_1.fromHex("30460221009cf7d941dcbbbe61c2a6f5112cb518094e79e5d203891de2247e75fd532c3f21022100fc5a04579b2526f2543efd2a57e82b647da08b6924bff39cf021398a56ad70de"),
message: (0, encoding_1.fromHex)("6f8983e74f304c3657cffde0682b42699cb2c3475b925058ff37292c40a0aa296690ad129730339ac60cf784225b2fd3db58297c8ce5889df7a48d3e74a363ae4135e8a234cab53ca4c11c031d561a6cf7dd47b925ed5bc4c2794ba7b74a868b0c3da31ff1e4540d0768612192a236d86f74fb8c73f375b71c62f1648c0e6126"),
privkey: (0, encoding_1.fromHex)("a70eb435feaeb6ccda7d3ebd3c4ae40b60643bc933f37ad1aca41dd086e8ae50"),
signature: (0, encoding_1.fromHex)("30460221009cf7d941dcbbbe61c2a6f5112cb518094e79e5d203891de2247e75fd532c3f21022100fc5a04579b2526f2543efd2a57e82b647da08b6924bff39cf021398a56ad70de"),
},
{
message: encoding_1.fromHex("6fbe6f0f178fdc8a3ad1a8eecb02d37108c5831281fe85e3ff8eeb66ca1082a217b6d602439948f828e140140412544f994da75b6efc203b295235deca060ecfc7b71f05e5af2acc564596772ddbfb4078b4665f6b85f4e70641af26e31f6a14e5c88604459df4eeeed9b77b33c4b82a3c1458bd2fd1dc7214c04f9c79c8f09b"),
privkey: encoding_1.fromHex("34a677d6f0c132eeffc3451b61e5d55969399699019ac929e6fdb5215d37be5e"),
signature: encoding_1.fromHex("3045022059cd6c2a30227afbd693d87b201d0989435d6e116c144276a5223466a822c0f2022100b01495efda969b3fd3a2c05aa098a4e04b0d0e748726fc6174627da15b143799"),
message: (0, encoding_1.fromHex)("6fbe6f0f178fdc8a3ad1a8eecb02d37108c5831281fe85e3ff8eeb66ca1082a217b6d602439948f828e140140412544f994da75b6efc203b295235deca060ecfc7b71f05e5af2acc564596772ddbfb4078b4665f6b85f4e70641af26e31f6a14e5c88604459df4eeeed9b77b33c4b82a3c1458bd2fd1dc7214c04f9c79c8f09b"),
privkey: (0, encoding_1.fromHex)("34a677d6f0c132eeffc3451b61e5d55969399699019ac929e6fdb5215d37be5e"),
signature: (0, encoding_1.fromHex)("3045022059cd6c2a30227afbd693d87b201d0989435d6e116c144276a5223466a822c0f2022100b01495efda969b3fd3a2c05aa098a4e04b0d0e748726fc6174627da15b143799"),
},
{
message: encoding_1.fromHex("2b49de971bb0f705a3fb5914eb7638d72884a6c3550667dbfdf301adf26bde02f387fd426a31be6c9ff8bfe8690c8113c88576427f1466508458349fc86036afcfb66448b947707e791e71f558b2bf4e7e7507773aaf4e9af51eda95cbce0a0f752b216f8a54a045d47801ff410ee411a1b66a516f278327df2462fb5619470e"),
privkey: encoding_1.fromHex("2258cdecaf3510bc398d08c000245cadceadcf149022730d93b176b4844713e1"),
signature: encoding_1.fromHex("30460221009eaf69170aeba44966afe957295526ee9852b5034c18dc5aeef3255c8567838a022100ebd4c8de2c22b5cb8803d6e070186786f6d5dae2202b9f899276fa31a66cb3bb"),
message: (0, encoding_1.fromHex)("2b49de971bb0f705a3fb5914eb7638d72884a6c3550667dbfdf301adf26bde02f387fd426a31be6c9ff8bfe8690c8113c88576427f1466508458349fc86036afcfb66448b947707e791e71f558b2bf4e7e7507773aaf4e9af51eda95cbce0a0f752b216f8a54a045d47801ff410ee411a1b66a516f278327df2462fb5619470e"),
privkey: (0, encoding_1.fromHex)("2258cdecaf3510bc398d08c000245cadceadcf149022730d93b176b4844713e1"),
signature: (0, encoding_1.fromHex)("30460221009eaf69170aeba44966afe957295526ee9852b5034c18dc5aeef3255c8567838a022100ebd4c8de2c22b5cb8803d6e070186786f6d5dae2202b9f899276fa31a66cb3bb"),
},
{
message: encoding_1.fromHex("1fa7201d96ad4d190415f2656d1387fa886afc38e5cd18b8c60da367acf32c627d2c9ea19ef3f030e559fc2a21695cdbb65ddf6ba36a70af0d3fa292a32de31da6acc6108ab2be8bd37843338f0c37c2d62648d3d49013edeb9e179dadf78bf885f95e712fcdfcc8a172e47c09ab159f3a00ed7b930f628c3c48257e92fc7407"),
privkey: encoding_1.fromHex("a67cf8cead99827c7956327aa04ab30cfd2d67f21b78f28a35694ece51052a61"),
signature: encoding_1.fromHex("304402210091058d1b912514940e1002855cc930c01a21234bad88f607f213af495c32b69f021f5d387ce3de25f1b9bad1fb180de110686d91b461ae2972fa4e4a7018519870"),
message: (0, encoding_1.fromHex)("1fa7201d96ad4d190415f2656d1387fa886afc38e5cd18b8c60da367acf32c627d2c9ea19ef3f030e559fc2a21695cdbb65ddf6ba36a70af0d3fa292a32de31da6acc6108ab2be8bd37843338f0c37c2d62648d3d49013edeb9e179dadf78bf885f95e712fcdfcc8a172e47c09ab159f3a00ed7b930f628c3c48257e92fc7407"),
privkey: (0, encoding_1.fromHex)("a67cf8cead99827c7956327aa04ab30cfd2d67f21b78f28a35694ece51052a61"),
signature: (0, encoding_1.fromHex)("304402210091058d1b912514940e1002855cc930c01a21234bad88f607f213af495c32b69f021f5d387ce3de25f1b9bad1fb180de110686d91b461ae2972fa4e4a7018519870"),
},
{
message: encoding_1.fromHex("74715fe10748a5b98b138f390f7ca9629c584c5d6ad268fc455c8de2e800b73fa1ea9aaee85de58baa2ce9ce68d822fc31842c6b153baef3a12bf6b4541f74af65430ae931a64c8b4950ad1c76b31aea8c229b3623390e233c112586aa5907bbe419841f54f0a7d6d19c003b91dc84bbb59b14ec477a1e9d194c137e21c75bbb"),
privkey: encoding_1.fromHex("4f1050422c4fce146bab0d735a70a91d6447210964b064309f90315c986be400"),
signature: encoding_1.fromHex("3046022100fe43eb9c38b506d118e20f8605ac8954fc0406efd306ba7ea5b07577a2735d15022100d589e91bf5014c7c360342ad135259dd7ae684e2c21234d7a912b43d148fcf19"),
message: (0, encoding_1.fromHex)("74715fe10748a5b98b138f390f7ca9629c584c5d6ad268fc455c8de2e800b73fa1ea9aaee85de58baa2ce9ce68d822fc31842c6b153baef3a12bf6b4541f74af65430ae931a64c8b4950ad1c76b31aea8c229b3623390e233c112586aa5907bbe419841f54f0a7d6d19c003b91dc84bbb59b14ec477a1e9d194c137e21c75bbb"),
privkey: (0, encoding_1.fromHex)("4f1050422c4fce146bab0d735a70a91d6447210964b064309f90315c986be400"),
signature: (0, encoding_1.fromHex)("3046022100fe43eb9c38b506d118e20f8605ac8954fc0406efd306ba7ea5b07577a2735d15022100d589e91bf5014c7c360342ad135259dd7ae684e2c21234d7a912b43d148fcf19"),
},
{
message: encoding_1.fromHex("d10131982dd1a1d839aba383cd72855bf41061c0cb04dfa1acad3181f240341d744ca6002b52f25fb3c63f16d050c4a4ef2c0ebf5f16ce987558f4b9d4a5ad3c6b81b617de00e04ba32282d8bf223bfedbb325b741dfdc8f56fa85c65d42f05f6a1330d8cc6664ad32050dd7b9e3993f4d6c91e5e12cbd9e82196e009ad22560"),
privkey: encoding_1.fromHex("79506f5f68941c60a0d7c62595652a5f42f2b9f5aa2b6456af1c56a79a346c2f"),
signature: encoding_1.fromHex("3046022100ccdbbd2500043bf7f705536d5984ab5f05fdc0fa3cf464d8c88f861e3fc8e54c022100d5c6342c08dcd8242e1daf3595cae968e320a025aa45ec4bc725795da3d1becb"),
message: (0, encoding_1.fromHex)("d10131982dd1a1d839aba383cd72855bf41061c0cb04dfa1acad3181f240341d744ca6002b52f25fb3c63f16d050c4a4ef2c0ebf5f16ce987558f4b9d4a5ad3c6b81b617de00e04ba32282d8bf223bfedbb325b741dfdc8f56fa85c65d42f05f6a1330d8cc6664ad32050dd7b9e3993f4d6c91e5e12cbd9e82196e009ad22560"),
privkey: (0, encoding_1.fromHex)("79506f5f68941c60a0d7c62595652a5f42f2b9f5aa2b6456af1c56a79a346c2f"),
signature: (0, encoding_1.fromHex)("3046022100ccdbbd2500043bf7f705536d5984ab5f05fdc0fa3cf464d8c88f861e3fc8e54c022100d5c6342c08dcd8242e1daf3595cae968e320a025aa45ec4bc725795da3d1becb"),
},
{
message: encoding_1.fromHex("ef9dbd90ded96ad627a0a987ab90537a3e7acc1fdfa991088e9d999fd726e3ce1e1bd89a7df08d8c2bf51085254c89dc67bc21e8a1a93f33a38c18c0ce3880e958ac3e3dbe8aec49f981821c4ac6812dd29fab3a9ebe7fbd799fb50f12021b48d1d9abca8842547b3b99befa612cc8b4ca5f9412e0352e72ab1344a0ac2913db"),
privkey: encoding_1.fromHex("4c53b8e372f70593afb08fb0f3ba228e1bd2430f562414e9bd1b89e53becbac8"),
signature: encoding_1.fromHex("304402205c707b6df7667324f950216b933d28e307a0223b24d161bc5887208d7f880b3a02204b7bc56586dc51d806ac3ad72807bc62d1d06d0812f121bd91e9770d84885c39"),
message: (0, encoding_1.fromHex)("ef9dbd90ded96ad627a0a987ab90537a3e7acc1fdfa991088e9d999fd726e3ce1e1bd89a7df08d8c2bf51085254c89dc67bc21e8a1a93f33a38c18c0ce3880e958ac3e3dbe8aec49f981821c4ac6812dd29fab3a9ebe7fbd799fb50f12021b48d1d9abca8842547b3b99befa612cc8b4ca5f9412e0352e72ab1344a0ac2913db"),
privkey: (0, encoding_1.fromHex)("4c53b8e372f70593afb08fb0f3ba228e1bd2430f562414e9bd1b89e53becbac8"),
signature: (0, encoding_1.fromHex)("304402205c707b6df7667324f950216b933d28e307a0223b24d161bc5887208d7f880b3a02204b7bc56586dc51d806ac3ad72807bc62d1d06d0812f121bd91e9770d84885c39"),
},

@@ -253,3 +253,3 @@ ];

const pubkey = (await secp256k1_1.Secp256k1.makeKeypair(row.privkey)).pubkey;
const messageHash = sha_1.sha256(row.message);
const messageHash = (0, sha_1.sha256)(row.message);
const isValid = await secp256k1_1.Secp256k1.verifySignature(secp256k1signature_1.Secp256k1Signature.fromDer(row.signature), messageHash, pubkey);

@@ -263,50 +263,50 @@ expect(isValid).withContext(`(index ${index})`).toEqual(true);

{
message: encoding_1.fromHex("5c868fedb8026979ebd26f1ba07c27eedf4ff6d10443505a96ecaf21ba8c4f0937b3cd23ffdc3dd429d4cd1905fb8dbcceeff1350020e18b58d2ba70887baa3a9b783ad30d3fbf210331cdd7df8d77defa398cdacdfc2e359c7ba4cae46bb74401deb417f8b912a1aa966aeeba9c39c7dd22479ae2b30719dca2f2206c5eb4b7"),
privkey: encoding_1.fromHex("1812bcfaa7566ba0724846d47dd4cc39306a506382cba33710ce6abd4d86553c"),
signature: encoding_1.fromHex("3044022045c0b7f8c09a9e1f1cea0c25785594427b6bf8f9f878a8af0b1abbb48e16d09202200d8becd0c220f67c51217eecfd7184ef0732481c843857e6bc7fc095c4f6b788"),
message: (0, encoding_1.fromHex)("5c868fedb8026979ebd26f1ba07c27eedf4ff6d10443505a96ecaf21ba8c4f0937b3cd23ffdc3dd429d4cd1905fb8dbcceeff1350020e18b58d2ba70887baa3a9b783ad30d3fbf210331cdd7df8d77defa398cdacdfc2e359c7ba4cae46bb74401deb417f8b912a1aa966aeeba9c39c7dd22479ae2b30719dca2f2206c5eb4b7"),
privkey: (0, encoding_1.fromHex)("1812bcfaa7566ba0724846d47dd4cc39306a506382cba33710ce6abd4d86553c"),
signature: (0, encoding_1.fromHex)("3044022045c0b7f8c09a9e1f1cea0c25785594427b6bf8f9f878a8af0b1abbb48e16d09202200d8becd0c220f67c51217eecfd7184ef0732481c843857e6bc7fc095c4f6b788"),
},
{
message: encoding_1.fromHex("17cd4a74d724d55355b6fb2b0759ca095298e3fd1856b87ca1cb2df5409058022736d21be071d820b16dfc441be97fbcea5df787edc886e759475469e2128b22f26b82ca993be6695ab190e673285d561d3b6d42fcc1edd6d12db12dcda0823e9d6079e7bc5ff54cd452dad308d52a15ce9c7edd6ef3dad6a27becd8e001e80f"),
privkey: encoding_1.fromHex("1aea57ea357cecc13b876b76a1825f433ff603d76e6794fdb55aeda481b9482b"),
signature: encoding_1.fromHex("304402204e0ea79d4a476276e4b067facdec7460d2c98c8a65326a6e5c998fd7c650611402200e45aea5034af973410e65cf97651b3f2b976e3fc79c6a93065ed7cb69a2ab5a"),
message: (0, encoding_1.fromHex)("17cd4a74d724d55355b6fb2b0759ca095298e3fd1856b87ca1cb2df5409058022736d21be071d820b16dfc441be97fbcea5df787edc886e759475469e2128b22f26b82ca993be6695ab190e673285d561d3b6d42fcc1edd6d12db12dcda0823e9d6079e7bc5ff54cd452dad308d52a15ce9c7edd6ef3dad6a27becd8e001e80f"),
privkey: (0, encoding_1.fromHex)("1aea57ea357cecc13b876b76a1825f433ff603d76e6794fdb55aeda481b9482b"),
signature: (0, encoding_1.fromHex)("304402204e0ea79d4a476276e4b067facdec7460d2c98c8a65326a6e5c998fd7c650611402200e45aea5034af973410e65cf97651b3f2b976e3fc79c6a93065ed7cb69a2ab5a"),
},
{
message: encoding_1.fromHex("db0d31717b04802adbbae1997487da8773440923c09b869e12a57c36dda34af11b8897f266cd81c02a762c6b74ea6aaf45aaa3c52867eb8f270f5092a36b498f88b65b2ebda24afe675da6f25379d1e194d093e7a2f66e450568dbdffebff97c4597a00c96a5be9ba26deefcca8761c1354429622c8db269d6a0ec0cc7a8585c"),
privkey: encoding_1.fromHex("03708999fddd22091e93a8fd6b2205b662089a97507623cb5ce04240bcae55b8"),
signature: encoding_1.fromHex("3045022100f25b86e1d8a11d72475b3ed273b0781c7d7f6f9e1dae0dd5d3ee9b84f3fab891022063d9c4e1391de077244583e9a6e3d8e8e1f236a3bf5963735353b93b1a3ba935"),
message: (0, encoding_1.fromHex)("db0d31717b04802adbbae1997487da8773440923c09b869e12a57c36dda34af11b8897f266cd81c02a762c6b74ea6aaf45aaa3c52867eb8f270f5092a36b498f88b65b2ebda24afe675da6f25379d1e194d093e7a2f66e450568dbdffebff97c4597a00c96a5be9ba26deefcca8761c1354429622c8db269d6a0ec0cc7a8585c"),
privkey: (0, encoding_1.fromHex)("03708999fddd22091e93a8fd6b2205b662089a97507623cb5ce04240bcae55b8"),
signature: (0, encoding_1.fromHex)("3045022100f25b86e1d8a11d72475b3ed273b0781c7d7f6f9e1dae0dd5d3ee9b84f3fab891022063d9c4e1391de077244583e9a6e3d8e8e1f236a3bf5963735353b93b1a3ba935"),
},
{
message: encoding_1.fromHex("47c9deddfd8c841a63a99be96e972e40fa035ae10d929babfc86c437b9d5d495577a45b7f8a35ce3f880e7d8ae8cd8eb685cf41f0506e68046ccf5559232c674abb9c3683829dcc8002683c4f4ca3a29a7bfde20d96dd0f1a0ead847dea18f297f220f94932536ca4deacedc2c6701c3ee50e28e358dcc54cdbf69daf0eb87f6"),
privkey: encoding_1.fromHex("44da7ab9eab17b93175bf4d5388c6b334f35a3283215b9e602a264d2e831fea3"),
signature: encoding_1.fromHex("3045022100f2cab57d108aaf7c9c9dd061404447d59f968d1468b25dd827d624b64601c32a022077558dbf7bf90885b9128c371959085e9dd1b7d8a5c45b7265e8e7d9f125c008"),
message: (0, encoding_1.fromHex)("47c9deddfd8c841a63a99be96e972e40fa035ae10d929babfc86c437b9d5d495577a45b7f8a35ce3f880e7d8ae8cd8eb685cf41f0506e68046ccf5559232c674abb9c3683829dcc8002683c4f4ca3a29a7bfde20d96dd0f1a0ead847dea18f297f220f94932536ca4deacedc2c6701c3ee50e28e358dcc54cdbf69daf0eb87f6"),
privkey: (0, encoding_1.fromHex)("44da7ab9eab17b93175bf4d5388c6b334f35a3283215b9e602a264d2e831fea3"),
signature: (0, encoding_1.fromHex)("3045022100f2cab57d108aaf7c9c9dd061404447d59f968d1468b25dd827d624b64601c32a022077558dbf7bf90885b9128c371959085e9dd1b7d8a5c45b7265e8e7d9f125c008"),
},
{
message: encoding_1.fromHex("f15433188c2bbc93b2150bb2f34d36ba8ae49f8f7e4e81aed651c8fb2022b2a7e851c4dbbbc21c14e27380316bfdebb0a049246349537dba687581c1344e40f75afd2735bb21ea074861de6801d28b22e8beb76fdd25598812b2061ca3fba229daf59a4ab416704543b02e16b8136c22acc7e197748ae19b5cbbc160fdc3a8cd"),
privkey: encoding_1.fromHex("5452b1bf1b1d96929f7ee3637a1bca637490f97634e6d164aeddda3dbb243a26"),
signature: encoding_1.fromHex("3045022100d702bec0f058f5e18f5fcdb204f79250562f11121f5513ae1006c9b93ddafb11022063de551c508405a280a21fb007b660542b58fcd3256b7cea45e3f2ebe9a29ecd"),
message: (0, encoding_1.fromHex)("f15433188c2bbc93b2150bb2f34d36ba8ae49f8f7e4e81aed651c8fb2022b2a7e851c4dbbbc21c14e27380316bfdebb0a049246349537dba687581c1344e40f75afd2735bb21ea074861de6801d28b22e8beb76fdd25598812b2061ca3fba229daf59a4ab416704543b02e16b8136c22acc7e197748ae19b5cbbc160fdc3a8cd"),
privkey: (0, encoding_1.fromHex)("5452b1bf1b1d96929f7ee3637a1bca637490f97634e6d164aeddda3dbb243a26"),
signature: (0, encoding_1.fromHex)("3045022100d702bec0f058f5e18f5fcdb204f79250562f11121f5513ae1006c9b93ddafb11022063de551c508405a280a21fb007b660542b58fcd3256b7cea45e3f2ebe9a29ecd"),
},
{
message: encoding_1.fromHex("1bc796124b87793b7f7fdd53b896f8f0d0f2d2be36d1944e3c2a0ac5c6b2839f59a4b4fad200f8035ec98630c51ef0d40863a5ddd69b703d73f06b4afae8ad1a88e19b1b26e8c10b7bff953c05eccc82fd771b220910165f3a906b7c931683e431998d1fd06c32dd11b4f872bf980d547942f22124c7e50c9523321aee23a36d"),
privkey: encoding_1.fromHex("a4095a3d464d20ea154f4312c087bd22c8a92207717cca40b1f3267e13cbf05c"),
signature: encoding_1.fromHex("3045022100ae17ab6a3bd2ccd0901cc3904103e825895540bf416a5f717b74b529512e4c1802204bc049a8a2287cfccea77fb3769755ba92c35154c635448cf633244edf4f6fe1"),
message: (0, encoding_1.fromHex)("1bc796124b87793b7f7fdd53b896f8f0d0f2d2be36d1944e3c2a0ac5c6b2839f59a4b4fad200f8035ec98630c51ef0d40863a5ddd69b703d73f06b4afae8ad1a88e19b1b26e8c10b7bff953c05eccc82fd771b220910165f3a906b7c931683e431998d1fd06c32dd11b4f872bf980d547942f22124c7e50c9523321aee23a36d"),
privkey: (0, encoding_1.fromHex)("a4095a3d464d20ea154f4312c087bd22c8a92207717cca40b1f3267e13cbf05c"),
signature: (0, encoding_1.fromHex)("3045022100ae17ab6a3bd2ccd0901cc3904103e825895540bf416a5f717b74b529512e4c1802204bc049a8a2287cfccea77fb3769755ba92c35154c635448cf633244edf4f6fe1"),
},
{
message: encoding_1.fromHex("18e55ac264031da435b613fc9dc6c4aafc49aae8ddf6f220d523415896ff915fae5c5b2e6aed61d88e5721823f089c46173afc5d9b47fd917834c85284f62dda6ed2d7a6ff10eb553b9312b05dad7decf7f73b69479c02f14ea0a2aa9e05ec07396cd37c28795c90e590631137102315635d702278e352aa41d0826adadff5e1"),
privkey: encoding_1.fromHex("4babce8321dcd2b5e3ac936e278519fb4b9be96688bbefb2e87d53b863a349b8"),
signature: encoding_1.fromHex("3044022003b51d02eac41f2969fc36c816c9772da21a139376b09d1c8809bb8f543be62f02200629c1396ae304d2c2e7b63890d91e56dfc3459f4d664cb914c7ff2a12a21925"),
message: (0, encoding_1.fromHex)("18e55ac264031da435b613fc9dc6c4aafc49aae8ddf6f220d523415896ff915fae5c5b2e6aed61d88e5721823f089c46173afc5d9b47fd917834c85284f62dda6ed2d7a6ff10eb553b9312b05dad7decf7f73b69479c02f14ea0a2aa9e05ec07396cd37c28795c90e590631137102315635d702278e352aa41d0826adadff5e1"),
privkey: (0, encoding_1.fromHex)("4babce8321dcd2b5e3ac936e278519fb4b9be96688bbefb2e87d53b863a349b8"),
signature: (0, encoding_1.fromHex)("3044022003b51d02eac41f2969fc36c816c9772da21a139376b09d1c8809bb8f543be62f02200629c1396ae304d2c2e7b63890d91e56dfc3459f4d664cb914c7ff2a12a21925"),
},
{
message: encoding_1.fromHex("a5290666c97294d090f8da898e555cbd33990579e5e95498444bfb318b4aa1643e0d4348425e21c7c6f99f9955f3048f56c22b68c4a516af5c90ed5268acc9c5a20fec0200c2a282a90e20d3c46d4ecdda18ba18b803b19263de2b79238da921707a0864799cdee9f02913b40681c02c6923070688844b58fe415b7d71ea6845"),
privkey: encoding_1.fromHex("02f98a6eb5320fc0c65f3eb2911b8500bedf47230bdfa2ba5e1c0c1c0bf9fc0a"),
signature: encoding_1.fromHex("30440220400f52f4c4925b4b8886706331535230fafb6455c3a3eef6fbf19a82593812300220727cc4b3341d7d95d0dc404d910dc009b3b5f21baadc0c4ee199a46e558d7f56"),
message: (0, encoding_1.fromHex)("a5290666c97294d090f8da898e555cbd33990579e5e95498444bfb318b4aa1643e0d4348425e21c7c6f99f9955f3048f56c22b68c4a516af5c90ed5268acc9c5a20fec0200c2a282a90e20d3c46d4ecdda18ba18b803b19263de2b79238da921707a0864799cdee9f02913b40681c02c6923070688844b58fe415b7d71ea6845"),
privkey: (0, encoding_1.fromHex)("02f98a6eb5320fc0c65f3eb2911b8500bedf47230bdfa2ba5e1c0c1c0bf9fc0a"),
signature: (0, encoding_1.fromHex)("30440220400f52f4c4925b4b8886706331535230fafb6455c3a3eef6fbf19a82593812300220727cc4b3341d7d95d0dc404d910dc009b3b5f21baadc0c4ee199a46e558d7f56"),
},
{
message: encoding_1.fromHex("13ad0600229c2a66b2f11617f69c7210ad044c49265dc98ec3c64f56e56a083234d277d404e2c40523c414ad23af5cc2f91a47fe59e7ca572f7fe1d3d3cfceaedadac4396749a292a38e92727273272335f12b2acea21cf069682e67d7e7d7a31ab5bb8e472298a9451aeae6f160f36e6623c9b632b9c93371a002818addc243"),
privkey: encoding_1.fromHex("f2a08a52b0edbaa64dacb3244666d4fdb684e6cc995bed81ec9d86c58f9999de"),
signature: encoding_1.fromHex("3045022100b2927afc8856b7e14d02e01e7aa3c76951a4621bfde5d794adda165b51dbe198022006eee6e0b087143ed06933cba699fbe4097ba7d7b038b173cbbd183718a86d43"),
message: (0, encoding_1.fromHex)("13ad0600229c2a66b2f11617f69c7210ad044c49265dc98ec3c64f56e56a083234d277d404e2c40523c414ad23af5cc2f91a47fe59e7ca572f7fe1d3d3cfceaedadac4396749a292a38e92727273272335f12b2acea21cf069682e67d7e7d7a31ab5bb8e472298a9451aeae6f160f36e6623c9b632b9c93371a002818addc243"),
privkey: (0, encoding_1.fromHex)("f2a08a52b0edbaa64dacb3244666d4fdb684e6cc995bed81ec9d86c58f9999de"),
signature: (0, encoding_1.fromHex)("3045022100b2927afc8856b7e14d02e01e7aa3c76951a4621bfde5d794adda165b51dbe198022006eee6e0b087143ed06933cba699fbe4097ba7d7b038b173cbbd183718a86d43"),
},
{
message: encoding_1.fromHex("51ad843da5eafc177d49a50a82609555e52773c5dfa14d7c02db5879c11a6b6e2e0860df38452dc579d763f91a83ade23b73f4fcbd703f35dd6ecfbb4c9578d5b604ed809c8633e6ac5679a5f742ce94fea3b97b5ba8a29ea28101a7b35f9eaa894dda54e3431f2464d18faf8342b7c59dfe0598c0ab29a14622a08eea70126b"),
privkey: encoding_1.fromHex("e27f10d444fa50b53283863941619b11d585b27018b0e29301371371b45e3c65"),
signature: encoding_1.fromHex("3044022100fe9717965673fbe585780e18d892a3cfa77b59ac2f44f5337a3e58ce6ecd4409021f155459b19d2e9a2e676d7d8d48a9303391ffb9befdd3a57324306d69e0e0ab"),
message: (0, encoding_1.fromHex)("51ad843da5eafc177d49a50a82609555e52773c5dfa14d7c02db5879c11a6b6e2e0860df38452dc579d763f91a83ade23b73f4fcbd703f35dd6ecfbb4c9578d5b604ed809c8633e6ac5679a5f742ce94fea3b97b5ba8a29ea28101a7b35f9eaa894dda54e3431f2464d18faf8342b7c59dfe0598c0ab29a14622a08eea70126b"),
privkey: (0, encoding_1.fromHex)("e27f10d444fa50b53283863941619b11d585b27018b0e29301371371b45e3c65"),
signature: (0, encoding_1.fromHex)("3044022100fe9717965673fbe585780e18d892a3cfa77b59ac2f44f5337a3e58ce6ecd4409021f155459b19d2e9a2e676d7d8d48a9303391ffb9befdd3a57324306d69e0e0ab"),
},

@@ -316,3 +316,3 @@ ];

const keypair = await secp256k1_1.Secp256k1.makeKeypair(row.privkey);
const messageHash = sha_1.sha256(row.message);
const messageHash = (0, sha_1.sha256)(row.message);
// create signature

@@ -334,5 +334,5 @@ const calculatedSignature = await secp256k1_1.Secp256k1.createSignature(messageHash, row.privkey);

// Test data from https://github.com/ethereumjs/ethereumjs-util/blob/v6.1.0/test/index.js#L496
const expectedPubkey = (await secp256k1_1.Secp256k1.makeKeypair(encoding_1.fromHex("3c9229289a6125f7fdf1885a77bb12c37a8d3b4962d936f7e3084dece32a3ca1"))).pubkey;
const signature = new secp256k1signature_1.ExtendedSecp256k1Signature(encoding_1.fromHex("99e71a99cb2270b8cac5254f9e99b6210c6c10224a1579cf389ef88b20a1abe9"), encoding_1.fromHex("129ff05af364204442bdb53ab6f18a99ab48acc9326fa689f228040429e3ca66"), 0);
const messageHash = encoding_1.fromHex("82ff40c0a986c6a5cfad4ddf4c3aa6996f1a7837f9c398e17e5de5cbd5a12b28");
const expectedPubkey = (await secp256k1_1.Secp256k1.makeKeypair((0, encoding_1.fromHex)("3c9229289a6125f7fdf1885a77bb12c37a8d3b4962d936f7e3084dece32a3ca1"))).pubkey;
const signature = new secp256k1signature_1.ExtendedSecp256k1Signature((0, encoding_1.fromHex)("99e71a99cb2270b8cac5254f9e99b6210c6c10224a1579cf389ef88b20a1abe9"), (0, encoding_1.fromHex)("129ff05af364204442bdb53ab6f18a99ab48acc9326fa689f228040429e3ca66"), 0);
const messageHash = (0, encoding_1.fromHex)("82ff40c0a986c6a5cfad4ddf4c3aa6996f1a7837f9c398e17e5de5cbd5a12b28");
const pubkey = secp256k1_1.Secp256k1.recoverPubkey(signature, messageHash);

@@ -345,7 +345,7 @@ expect(pubkey).toEqual(expectedPubkey);

const expectedPubkeyY = "A2ED51F08CA3EF3DAC0A7504613D54CD539FC1B3CBC92453CD704B6A2D012B2C";
const expectedPubkey = encoding_1.fromHex(`04${expectedPubkeyX}${expectedPubkeyY}`);
const r = encoding_1.fromHex("E30F2E6A0F705F4FB5F8501BA79C7C0D3FAC847F1AD70B873E9797B17B89B390");
const s = encoding_1.fromHex("81F1A4457589F30D76AB9F89E748A68C8A94C30FE0BAC8FB5C0B54EA70BF6D2F");
const expectedPubkey = (0, encoding_1.fromHex)(`04${expectedPubkeyX}${expectedPubkeyY}`);
const r = (0, encoding_1.fromHex)("E30F2E6A0F705F4FB5F8501BA79C7C0D3FAC847F1AD70B873E9797B17B89B390");
const s = (0, encoding_1.fromHex)("81F1A4457589F30D76AB9F89E748A68C8A94C30FE0BAC8FB5C0B54EA70BF6D2F");
const signature = new secp256k1signature_1.ExtendedSecp256k1Signature(r, s, 0);
const messageHash = encoding_1.fromHex("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
const messageHash = (0, encoding_1.fromHex)("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
const pubkey = secp256k1_1.Secp256k1.recoverPubkey(signature, messageHash);

@@ -358,7 +358,7 @@ expect(pubkey).toEqual(expectedPubkey);

it("throws for a pubkey with invalid length", () => {
const pubkey = encoding_1.fromHex("aa".repeat(32));
const pubkey = (0, encoding_1.fromHex)("aa".repeat(32));
expect(() => secp256k1_1.Secp256k1.compressPubkey(pubkey)).toThrowError(/invalid pubkey length/i);
});
it("returns a compressed pubkey unchanged", () => {
const pubkey = encoding_1.fromHex("02d41a0aa167b21699429eab224bc03f2cd386f0af5d20cefbd0336f1544aea24f");
const pubkey = (0, encoding_1.fromHex)("02d41a0aa167b21699429eab224bc03f2cd386f0af5d20cefbd0336f1544aea24f");
expect(secp256k1_1.Secp256k1.compressPubkey(pubkey)).toEqual(pubkey);

@@ -368,19 +368,36 @@ });

// Test data generated at https://iancoleman.io/bitcoin-key-compression/
const pubkey = encoding_1.fromHex("044f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029013b587a681e836cc187a8164b98a5848a2b89b3173315fdd0740d5032e259cd5");
const compressed = encoding_1.fromHex("034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c70290");
const pubkey = (0, encoding_1.fromHex)("044f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029013b587a681e836cc187a8164b98a5848a2b89b3173315fdd0740d5032e259cd5");
const compressed = (0, encoding_1.fromHex)("034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c70290");
expect(secp256k1_1.Secp256k1.compressPubkey(pubkey)).toEqual(compressed);
});
});
describe("uncompressPubkey", () => {
it("throws for a pubkey with invalid length", () => {
const pubkey = (0, encoding_1.fromHex)("aa".repeat(32));
expect(() => secp256k1_1.Secp256k1.uncompressPubkey(pubkey)).toThrowError(/invalid pubkey length/i);
});
it("returns an uncompressPubkey pubkey unchanged", () => {
// Test data generated at https://iancoleman.io/bitcoin-key-compression/
const pubkey = (0, encoding_1.fromHex)("044f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029013b587a681e836cc187a8164b98a5848a2b89b3173315fdd0740d5032e259cd5");
expect(secp256k1_1.Secp256k1.uncompressPubkey(pubkey)).toEqual(pubkey);
});
it("uncompresses a compressed pubkey", () => {
// Test data generated at https://iancoleman.io/bitcoin-key-compression/
const uncompressed = (0, encoding_1.fromHex)("044f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c7029013b587a681e836cc187a8164b98a5848a2b89b3173315fdd0740d5032e259cd5");
const compressed = (0, encoding_1.fromHex)("034f04181eeba35391b858633a765c4a0c189697b40d216354d50890d350c70290");
expect(secp256k1_1.Secp256k1.uncompressPubkey(compressed)).toEqual(uncompressed);
});
});
describe("trimRecoveryByte", () => {
it("throws for a signature with invalid length", () => {
const signature = encoding_1.fromHex("aa".repeat(66));
const signature = (0, encoding_1.fromHex)("aa".repeat(66));
expect(() => secp256k1_1.Secp256k1.trimRecoveryByte(signature)).toThrowError(/invalid signature length/i);
});
it("returns a trimmed signature", () => {
const signature = encoding_1.fromHex("aa".repeat(64));
const signature = (0, encoding_1.fromHex)("aa".repeat(64));
expect(secp256k1_1.Secp256k1.trimRecoveryByte(signature)).toEqual(signature);
});
it("trims a signature with recovery byte", () => {
const signature = encoding_1.fromHex("aa".repeat(64) + "bb");
expect(secp256k1_1.Secp256k1.trimRecoveryByte(signature)).toEqual(encoding_1.fromHex("aa".repeat(64)));
const signature = (0, encoding_1.fromHex)("aa".repeat(64) + "bb");
expect(secp256k1_1.Secp256k1.trimRecoveryByte(signature)).toEqual((0, encoding_1.fromHex)("aa".repeat(64)));
});

@@ -387,0 +404,0 @@ });

@@ -8,3 +8,3 @@ "use strict";

it("works", () => {
const data = encoding_1.fromHex("000000000000000000000000000000000000000000000000000000000000223300000000000000000000000000000000000000000000000000000000000000aa");
const data = (0, encoding_1.fromHex)("000000000000000000000000000000000000000000000000000000000000223300000000000000000000000000000000000000000000000000000000000000aa");
const signature = secp256k1signature_1.Secp256k1Signature.fromFixedLength(data);

@@ -15,3 +15,3 @@ expect(signature.r()).toEqual(new Uint8Array([0x22, 0x33]));

it("throws for invalid length", () => {
const data = encoding_1.fromHex("000000000000000000000000000000000000000000000000000000000000223300000000000000000000000000000000000000000000000000000000000000aa01");
const data = (0, encoding_1.fromHex)("000000000000000000000000000000000000000000000000000000000000223300000000000000000000000000000000000000000000000000000000000000aa01");
expect(() => secp256k1signature_1.Secp256k1Signature.fromFixedLength(data)).toThrowError(/got invalid data length/i);

@@ -31,8 +31,8 @@ });

const signature = new secp256k1signature_1.Secp256k1Signature(new Uint8Array([0x22, 0x33]), new Uint8Array([0xaa]));
expect(signature.r(2)).toEqual(encoding_1.fromHex("2233"));
expect(signature.r(5)).toEqual(encoding_1.fromHex("0000002233"));
expect(signature.r(32)).toEqual(encoding_1.fromHex("0000000000000000000000000000000000000000000000000000000000002233"));
expect(signature.s(1)).toEqual(encoding_1.fromHex("AA"));
expect(signature.s(2)).toEqual(encoding_1.fromHex("00AA"));
expect(signature.s(7)).toEqual(encoding_1.fromHex("000000000000AA"));
expect(signature.r(2)).toEqual((0, encoding_1.fromHex)("2233"));
expect(signature.r(5)).toEqual((0, encoding_1.fromHex)("0000002233"));
expect(signature.r(32)).toEqual((0, encoding_1.fromHex)("0000000000000000000000000000000000000000000000000000000000002233"));
expect(signature.s(1)).toEqual((0, encoding_1.fromHex)("AA"));
expect(signature.s(2)).toEqual((0, encoding_1.fromHex)("00AA"));
expect(signature.s(7)).toEqual((0, encoding_1.fromHex)("000000000000AA"));
});

@@ -48,10 +48,10 @@ it("throws when output size of r or s is too small", () => {

it("throws for r with leading 0", () => {
expect(() => new secp256k1signature_1.Secp256k1Signature(encoding_1.fromHex("00F25B86E1D8A11D72475B3ED273B0781C7D7F6F9E1DAE0DD5D3EE9B84F3FAB891"), new Uint8Array([0xaa]))).toThrowError(/unsigned integer r must be encoded as unpadded big endian./i);
expect(() => new secp256k1signature_1.Secp256k1Signature((0, encoding_1.fromHex)("00F25B86E1D8A11D72475B3ED273B0781C7D7F6F9E1DAE0DD5D3EE9B84F3FAB891"), new Uint8Array([0xaa]))).toThrowError(/unsigned integer r must be encoded as unpadded big endian./i);
});
it("throws for s with leading 0", () => {
expect(() => new secp256k1signature_1.Secp256k1Signature(new Uint8Array([0xaa]), encoding_1.fromHex("00F25B86E1D8A11D72475B3ED273B0781C7D7F6F9E1DAE0DD5D3EE9B84F3FAB891"))).toThrowError(/unsigned integer s must be encoded as unpadded big endian./i);
expect(() => new secp256k1signature_1.Secp256k1Signature(new Uint8Array([0xaa]), (0, encoding_1.fromHex)("00F25B86E1D8A11D72475B3ED273B0781C7D7F6F9E1DAE0DD5D3EE9B84F3FAB891"))).toThrowError(/unsigned integer s must be encoded as unpadded big endian./i);
});
it("can be encoded as fixed length", () => {
const signature = new secp256k1signature_1.Secp256k1Signature(new Uint8Array([0x22, 0x33]), new Uint8Array([0xaa]));
expect(signature.toFixedLength()).toEqual(encoding_1.fromHex("000000000000000000000000000000000000000000000000000000000000223300000000000000000000000000000000000000000000000000000000000000aa"));
expect(signature.toFixedLength()).toEqual((0, encoding_1.fromHex)("000000000000000000000000000000000000000000000000000000000000223300000000000000000000000000000000000000000000000000000000000000aa"));
});

@@ -61,4 +61,4 @@ it("can encode to DER", () => {

// decoded by http://asn1-playground.oss.com/
const signature = new secp256k1signature_1.Secp256k1Signature(encoding_1.fromHex("F25B86E1D8A11D72475B3ED273B0781C7D7F6F9E1DAE0DD5D3EE9B84F3FAB891"), encoding_1.fromHex("63D9C4E1391DE077244583E9A6E3D8E8E1F236A3BF5963735353B93B1A3BA935"));
expect(signature.toDer()).toEqual(encoding_1.fromHex("3045022100f25b86e1d8a11d72475b3ed273b0781c7d7f6f9e1dae0dd5d3ee9b84f3fab891022063d9c4e1391de077244583e9a6e3d8e8e1f236a3bf5963735353b93b1a3ba935"));
const signature = new secp256k1signature_1.Secp256k1Signature((0, encoding_1.fromHex)("F25B86E1D8A11D72475B3ED273B0781C7D7F6F9E1DAE0DD5D3EE9B84F3FAB891"), (0, encoding_1.fromHex)("63D9C4E1391DE077244583E9A6E3D8E8E1F236A3BF5963735353B93B1A3BA935"));
expect(signature.toDer()).toEqual((0, encoding_1.fromHex)("3045022100f25b86e1d8a11d72475b3ed273b0781c7d7f6f9e1dae0dd5d3ee9b84f3fab891022063d9c4e1391de077244583e9a6e3d8e8e1f236a3bf5963735353b93b1a3ba935"));
});

@@ -69,13 +69,13 @@ it("can decode from DER", () => {

// 70 bytes (no leading zeros)
const sig70 = secp256k1signature_1.Secp256k1Signature.fromDer(encoding_1.fromHex("30440220626d61b7be1488b563e8a85bfb623b2331903964b5c0476c9f9ad29144f076fe02202002a2c0ab5e48626bf761cf677dfeede9c7309d2436d4b8c2b89f21ee2ebc6a"));
expect(sig70.r()).toEqual(encoding_1.fromHex("626D61B7BE1488B563E8A85BFB623B2331903964B5C0476C9F9AD29144F076FE"));
expect(sig70.s()).toEqual(encoding_1.fromHex("2002A2C0AB5E48626BF761CF677DFEEDE9C7309D2436D4B8C2B89F21EE2EBC6A"));
const sig70 = secp256k1signature_1.Secp256k1Signature.fromDer((0, encoding_1.fromHex)("30440220626d61b7be1488b563e8a85bfb623b2331903964b5c0476c9f9ad29144f076fe02202002a2c0ab5e48626bf761cf677dfeede9c7309d2436d4b8c2b89f21ee2ebc6a"));
expect(sig70.r()).toEqual((0, encoding_1.fromHex)("626D61B7BE1488B563E8A85BFB623B2331903964B5C0476C9F9AD29144F076FE"));
expect(sig70.s()).toEqual((0, encoding_1.fromHex)("2002A2C0AB5E48626BF761CF677DFEEDE9C7309D2436D4B8C2B89F21EE2EBC6A"));
// 71 bytes (leading zero in r)
const sig71 = secp256k1signature_1.Secp256k1Signature.fromDer(encoding_1.fromHex("3045022100f25b86e1d8a11d72475b3ed273b0781c7d7f6f9e1dae0dd5d3ee9b84f3fab891022063d9c4e1391de077244583e9a6e3d8e8e1f236a3bf5963735353b93b1a3ba935"));
expect(sig71.r()).toEqual(encoding_1.fromHex("F25B86E1D8A11D72475B3ED273B0781C7D7F6F9E1DAE0DD5D3EE9B84F3FAB891"));
expect(sig71.s()).toEqual(encoding_1.fromHex("63D9C4E1391DE077244583E9A6E3D8E8E1F236A3BF5963735353B93B1A3BA935"));
const sig71 = secp256k1signature_1.Secp256k1Signature.fromDer((0, encoding_1.fromHex)("3045022100f25b86e1d8a11d72475b3ed273b0781c7d7f6f9e1dae0dd5d3ee9b84f3fab891022063d9c4e1391de077244583e9a6e3d8e8e1f236a3bf5963735353b93b1a3ba935"));
expect(sig71.r()).toEqual((0, encoding_1.fromHex)("F25B86E1D8A11D72475B3ED273B0781C7D7F6F9E1DAE0DD5D3EE9B84F3FAB891"));
expect(sig71.s()).toEqual((0, encoding_1.fromHex)("63D9C4E1391DE077244583E9A6E3D8E8E1F236A3BF5963735353B93B1A3BA935"));
// 72 bytes (leading zero in r and s)
const sig72 = secp256k1signature_1.Secp256k1Signature.fromDer(encoding_1.fromHex("304602210083de9be443bcf480892b8c8ca1d5ee65c79a315642c3f7b5305aff3065fda2780221009747932122b93cec42cad8ee4630a8f6cbe127578b8c495b4ab927275f657658"));
expect(sig72.r()).toEqual(encoding_1.fromHex("83DE9BE443BCF480892B8C8CA1D5EE65C79A315642C3F7B5305AFF3065FDA278"));
expect(sig72.s()).toEqual(encoding_1.fromHex("9747932122B93CEC42CAD8EE4630A8F6CBE127578B8C495B4AB927275F657658"));
const sig72 = secp256k1signature_1.Secp256k1Signature.fromDer((0, encoding_1.fromHex)("304602210083de9be443bcf480892b8c8ca1d5ee65c79a315642c3f7b5305aff3065fda2780221009747932122b93cec42cad8ee4630a8f6cbe127578b8c495b4ab927275f657658"));
expect(sig72.r()).toEqual((0, encoding_1.fromHex)("83DE9BE443BCF480892B8C8CA1D5EE65C79A315642C3F7B5305AFF3065FDA278"));
expect(sig72.s()).toEqual((0, encoding_1.fromHex)("9747932122B93CEC42CAD8EE4630A8F6CBE127578B8C495B4AB927275F657658"));
});

@@ -89,15 +89,15 @@ });

it("throws for recovery param out of range", () => {
expect(() => new secp256k1signature_1.ExtendedSecp256k1Signature(encoding_1.fromHex("aa"), encoding_1.fromHex("bb"), Number.NaN)).toThrowError(/the recovery parameter must be an integer/i);
expect(() => new secp256k1signature_1.ExtendedSecp256k1Signature(encoding_1.fromHex("aa"), encoding_1.fromHex("bb"), Number.NEGATIVE_INFINITY)).toThrowError(/the recovery parameter must be an integer/i);
expect(() => new secp256k1signature_1.ExtendedSecp256k1Signature(encoding_1.fromHex("aa"), encoding_1.fromHex("bb"), Number.POSITIVE_INFINITY)).toThrowError(/the recovery parameter must be an integer/i);
expect(() => new secp256k1signature_1.ExtendedSecp256k1Signature(encoding_1.fromHex("aa"), encoding_1.fromHex("bb"), 1.1)).toThrowError(/the recovery parameter must be an integer/i);
expect(() => new secp256k1signature_1.ExtendedSecp256k1Signature(encoding_1.fromHex("aa"), encoding_1.fromHex("bb"), -1)).toThrowError(/the recovery parameter must be one of 0, 1, 2, 3/i);
expect(() => new secp256k1signature_1.ExtendedSecp256k1Signature(encoding_1.fromHex("aa"), encoding_1.fromHex("bb"), 5)).toThrowError(/the recovery parameter must be one of 0, 1, 2, 3/i);
expect(() => new secp256k1signature_1.ExtendedSecp256k1Signature((0, encoding_1.fromHex)("aa"), (0, encoding_1.fromHex)("bb"), Number.NaN)).toThrowError(/the recovery parameter must be an integer/i);
expect(() => new secp256k1signature_1.ExtendedSecp256k1Signature((0, encoding_1.fromHex)("aa"), (0, encoding_1.fromHex)("bb"), Number.NEGATIVE_INFINITY)).toThrowError(/the recovery parameter must be an integer/i);
expect(() => new secp256k1signature_1.ExtendedSecp256k1Signature((0, encoding_1.fromHex)("aa"), (0, encoding_1.fromHex)("bb"), Number.POSITIVE_INFINITY)).toThrowError(/the recovery parameter must be an integer/i);
expect(() => new secp256k1signature_1.ExtendedSecp256k1Signature((0, encoding_1.fromHex)("aa"), (0, encoding_1.fromHex)("bb"), 1.1)).toThrowError(/the recovery parameter must be an integer/i);
expect(() => new secp256k1signature_1.ExtendedSecp256k1Signature((0, encoding_1.fromHex)("aa"), (0, encoding_1.fromHex)("bb"), -1)).toThrowError(/the recovery parameter must be one of 0, 1, 2, 3/i);
expect(() => new secp256k1signature_1.ExtendedSecp256k1Signature((0, encoding_1.fromHex)("aa"), (0, encoding_1.fromHex)("bb"), 5)).toThrowError(/the recovery parameter must be one of 0, 1, 2, 3/i);
});
it("can be encoded as fixed length", () => {
const signature = new secp256k1signature_1.ExtendedSecp256k1Signature(new Uint8Array([0x22, 0x33]), new Uint8Array([0xaa]), 1);
expect(signature.toFixedLength()).toEqual(encoding_1.fromHex("000000000000000000000000000000000000000000000000000000000000223300000000000000000000000000000000000000000000000000000000000000aa01"));
expect(signature.toFixedLength()).toEqual((0, encoding_1.fromHex)("000000000000000000000000000000000000000000000000000000000000223300000000000000000000000000000000000000000000000000000000000000aa01"));
});
it("can be decoded from fixed length", () => {
const signature = secp256k1signature_1.ExtendedSecp256k1Signature.fromFixedLength(encoding_1.fromHex("000000000000000000000000000000000000000000000000000000000000223300000000000000000000000000000000000000000000000000000000000000aa01"));
const signature = secp256k1signature_1.ExtendedSecp256k1Signature.fromFixedLength((0, encoding_1.fromHex)("000000000000000000000000000000000000000000000000000000000000223300000000000000000000000000000000000000000000000000000000000000aa01"));
expect(signature.r()).toEqual(new Uint8Array([0x22, 0x33]));

@@ -104,0 +104,0 @@ expect(signature.s()).toEqual(new Uint8Array([0xaa]));

import { HashFunction } from "./hash";
export declare class Sha1 implements HashFunction {
readonly blockSize: number;
private readonly impl;
constructor(firstData?: Uint8Array);
update(data: Uint8Array): Sha1;
digest(): Uint8Array;
}
/** Convenience function equivalent to `new Sha1(data).digest()` */
export declare function sha1(data: Uint8Array): Uint8Array;
export declare class Sha256 implements HashFunction {

@@ -12,0 +3,0 @@ readonly blockSize: number;

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.sha512 = exports.Sha512 = exports.sha256 = exports.Sha256 = exports.sha1 = exports.Sha1 = void 0;
const sha_js_1 = __importDefault(require("sha.js"));
class Sha1 {
constructor(firstData) {
this.blockSize = 512 / 8;
this.impl = sha_js_1.default("sha1");
if (firstData) {
this.update(firstData);
}
}
update(data) {
this.impl.update(data);
return this;
}
digest() {
return new Uint8Array(this.impl.digest());
}
}
exports.Sha1 = Sha1;
/** Convenience function equivalent to `new Sha1(data).digest()` */
function sha1(data) {
return new Sha1(data).digest();
}
exports.sha1 = sha1;
exports.sha512 = exports.Sha512 = exports.sha256 = exports.Sha256 = void 0;
const sha256_1 = require("@noble/hashes/sha256");
const sha512_1 = require("@noble/hashes/sha512");
const utils_1 = require("./utils");
class Sha256 {
constructor(firstData) {
this.blockSize = 512 / 8;
this.impl = sha_js_1.default("sha256");
this.impl = sha256_1.sha256.create();
if (firstData) {

@@ -39,7 +16,7 @@ this.update(firstData);

update(data) {
this.impl.update(data);
this.impl.update((0, utils_1.toRealUint8Array)(data));
return this;
}
digest() {
return new Uint8Array(this.impl.digest());
return this.impl.digest();
}

@@ -56,3 +33,3 @@ }

this.blockSize = 1024 / 8;
this.impl = sha_js_1.default("sha512");
this.impl = sha512_1.sha512.create();
if (firstData) {

@@ -63,7 +40,7 @@ this.update(firstData);

update(data) {
this.impl.update(data);
this.impl.update((0, utils_1.toRealUint8Array)(data));
return this;
}
digest() {
return new Uint8Array(this.impl.digest());
return this.impl.digest();
}

@@ -70,0 +47,0 @@ }

@@ -16,7 +16,7 @@ "use strict";

const hash = new sha_1.Sha256(new Uint8Array([])).digest();
expect(encoding_1.toHex(hash)).toEqual("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
expect((0, encoding_1.toHex)(hash)).toEqual("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
}
{
const hash = new sha_1.Sha256().digest();
expect(encoding_1.toHex(hash)).toEqual("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
expect((0, encoding_1.toHex)(hash)).toEqual("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
}

@@ -27,3 +27,3 @@ });

for (const { in: input, out: output } of sha_json_1.default.sha256) {
expect(new sha_1.Sha256(encoding_1.fromHex(input)).digest()).toEqual(encoding_1.fromHex(output));
expect(new sha_1.Sha256((0, encoding_1.fromHex)(input)).digest()).toEqual((0, encoding_1.fromHex)(output));
}

@@ -33,5 +33,5 @@ });

const { in: input, out: output } = sha_json_1.default.sha256[0];
expect(sha_1.sha256(encoding_1.fromHex(input))).toEqual(encoding_1.fromHex(output));
expect((0, sha_1.sha256)((0, encoding_1.fromHex)(input))).toEqual((0, encoding_1.fromHex)(output));
});
});
//# sourceMappingURL=sha.spec.js.map

@@ -61,3 +61,3 @@ "use strict";

static master(curve, seed) {
const i = new hmac_1.Hmac(sha_1.Sha512, encoding_1.toAscii(curve)).update(seed).digest();
const i = new hmac_1.Hmac(sha_1.Sha512, (0, encoding_1.toAscii)(curve)).update(seed).digest();
const il = i.slice(0, 32);

@@ -104,3 +104,3 @@ const ir = i.slice(32, 64);

case Slip10Curve.Secp256k1:
return encoding_1.fromHex(secp256k1.g.mul(p).encodeCompressed("hex"));
return (0, encoding_1.fromHex)(secp256k1.g.mul(p).encodeCompressed("hex"));
default:

@@ -107,0 +107,0 @@ throw new Error("curve not supported");

@@ -7,15 +7,15 @@ "use strict";

it("has working slip10CurveFromString()", () => {
expect(slip10_1.slip10CurveFromString("Bitcoin seed")).toEqual(slip10_1.Slip10Curve.Secp256k1);
expect(slip10_1.slip10CurveFromString("ed25519 seed")).toEqual(slip10_1.Slip10Curve.Ed25519);
expect(() => slip10_1.slip10CurveFromString("something else")).toThrowError(/unknown curve/i);
expect(() => slip10_1.slip10CurveFromString("")).toThrowError(/unknown curve/i);
expect((0, slip10_1.slip10CurveFromString)("Bitcoin seed")).toEqual(slip10_1.Slip10Curve.Secp256k1);
expect((0, slip10_1.slip10CurveFromString)("ed25519 seed")).toEqual(slip10_1.Slip10Curve.Ed25519);
expect(() => (0, slip10_1.slip10CurveFromString)("something else")).toThrowError(/unknown curve/i);
expect(() => (0, slip10_1.slip10CurveFromString)("")).toThrowError(/unknown curve/i);
});
describe("Test vector 1 for secp256k1", () => {
// https://github.com/satoshilabs/slips/blob/master/slip-0010.md#test-vector-1-for-secp256k1
const seed = encoding_1.fromHex("000102030405060708090a0b0c0d0e0f");
const seed = (0, encoding_1.fromHex)("000102030405060708090a0b0c0d0e0f");
it("can derive path m", () => {
const path = [];
const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Secp256k1, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("873dff81c02f525623fd1fe5167eac3a55a049de3d314bb42ee227ffed37d508"));
expect(derived.privkey).toEqual(encoding_1.fromHex("e8f32e723decf4051aefac8e2c93c9c5b214313817cdb01a1494b917c8436b35"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("873dff81c02f525623fd1fe5167eac3a55a049de3d314bb42ee227ffed37d508"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("e8f32e723decf4051aefac8e2c93c9c5b214313817cdb01a1494b917c8436b35"));
});

@@ -25,4 +25,4 @@ it("can derive path m/0'", () => {

const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Secp256k1, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("47fdacbd0f1097043b78c63c20c34ef4ed9a111d980047ad16282c7ae6236141"));
expect(derived.privkey).toEqual(encoding_1.fromHex("edb2e14f9ee77d26dd93b4ecede8d16ed408ce149b6cd80b0715a2d911a0afea"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("47fdacbd0f1097043b78c63c20c34ef4ed9a111d980047ad16282c7ae6236141"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("edb2e14f9ee77d26dd93b4ecede8d16ed408ce149b6cd80b0715a2d911a0afea"));
});

@@ -32,4 +32,4 @@ it("can derive path m/0'/1", () => {

const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Secp256k1, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("2a7857631386ba23dacac34180dd1983734e444fdbf774041578e9b6adb37c19"));
expect(derived.privkey).toEqual(encoding_1.fromHex("3c6cb8d0f6a264c91ea8b5030fadaa8e538b020f0a387421a12de9319dc93368"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("2a7857631386ba23dacac34180dd1983734e444fdbf774041578e9b6adb37c19"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("3c6cb8d0f6a264c91ea8b5030fadaa8e538b020f0a387421a12de9319dc93368"));
});

@@ -39,4 +39,4 @@ it("can derive path m/0'/1/2'", () => {

const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Secp256k1, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("04466b9cc8e161e966409ca52986c584f07e9dc81f735db683c3ff6ec7b1503f"));
expect(derived.privkey).toEqual(encoding_1.fromHex("cbce0d719ecf7431d88e6a89fa1483e02e35092af60c042b1df2ff59fa424dca"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("04466b9cc8e161e966409ca52986c584f07e9dc81f735db683c3ff6ec7b1503f"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("cbce0d719ecf7431d88e6a89fa1483e02e35092af60c042b1df2ff59fa424dca"));
});

@@ -51,4 +51,4 @@ it("can derive path m/0'/1/2'/2", () => {

const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Secp256k1, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("cfb71883f01676f587d023cc53a35bc7f88f724b1f8c2892ac1275ac822a3edd"));
expect(derived.privkey).toEqual(encoding_1.fromHex("0f479245fb19a38a1954c5c7c0ebab2f9bdfd96a17563ef28a6a4b1a2a764ef4"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("cfb71883f01676f587d023cc53a35bc7f88f724b1f8c2892ac1275ac822a3edd"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("0f479245fb19a38a1954c5c7c0ebab2f9bdfd96a17563ef28a6a4b1a2a764ef4"));
});

@@ -64,4 +64,4 @@ it("can derive path m/0'/1/2'/2/1000000000", () => {

const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Secp256k1, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("c783e67b921d2beb8f6b389cc646d7263b4145701dadd2161548a8b078e65e9e"));
expect(derived.privkey).toEqual(encoding_1.fromHex("471b76e389e528d6de6d816857e012c5455051cad6660850e58372a6c3e6e7c8"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("c783e67b921d2beb8f6b389cc646d7263b4145701dadd2161548a8b078e65e9e"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("471b76e389e528d6de6d816857e012c5455051cad6660850e58372a6c3e6e7c8"));
});

@@ -71,8 +71,8 @@ });

// https://github.com/satoshilabs/slips/blob/master/slip-0010.md#test-vector-2-for-secp256k1
const seed = encoding_1.fromHex("fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542");
const seed = (0, encoding_1.fromHex)("fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542");
it("can derive path m", () => {
const path = [];
const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Secp256k1, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("60499f801b896d83179a4374aeb7822aaeaceaa0db1f85ee3e904c4defbd9689"));
expect(derived.privkey).toEqual(encoding_1.fromHex("4b03d6fc340455b363f51020ad3ecca4f0850280cf436c70c727923f6db46c3e"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("60499f801b896d83179a4374aeb7822aaeaceaa0db1f85ee3e904c4defbd9689"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("4b03d6fc340455b363f51020ad3ecca4f0850280cf436c70c727923f6db46c3e"));
});

@@ -82,4 +82,4 @@ it("can derive path m/0", () => {

const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Secp256k1, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("f0909affaa7ee7abe5dd4e100598d4dc53cd709d5a5c2cac40e7412f232f7c9c"));
expect(derived.privkey).toEqual(encoding_1.fromHex("abe74a98f6c7eabee0428f53798f0ab8aa1bd37873999041703c742f15ac7e1e"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("f0909affaa7ee7abe5dd4e100598d4dc53cd709d5a5c2cac40e7412f232f7c9c"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("abe74a98f6c7eabee0428f53798f0ab8aa1bd37873999041703c742f15ac7e1e"));
});

@@ -89,4 +89,4 @@ it("can derive path m/0/2147483647'", () => {

const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Secp256k1, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("be17a268474a6bb9c61e1d720cf6215e2a88c5406c4aee7b38547f585c9a37d9"));
expect(derived.privkey).toEqual(encoding_1.fromHex("877c779ad9687164e9c2f4f0f4ff0340814392330693ce95a58fe18fd52e6e93"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("be17a268474a6bb9c61e1d720cf6215e2a88c5406c4aee7b38547f585c9a37d9"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("877c779ad9687164e9c2f4f0f4ff0340814392330693ce95a58fe18fd52e6e93"));
});

@@ -100,4 +100,4 @@ it("can derive path m/0/2147483647'/1", () => {

const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Secp256k1, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("f366f48f1ea9f2d1d3fe958c95ca84ea18e4c4ddb9366c336c927eb246fb38cb"));
expect(derived.privkey).toEqual(encoding_1.fromHex("704addf544a06e5ee4bea37098463c23613da32020d604506da8c0518e1da4b7"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("f366f48f1ea9f2d1d3fe958c95ca84ea18e4c4ddb9366c336c927eb246fb38cb"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("704addf544a06e5ee4bea37098463c23613da32020d604506da8c0518e1da4b7"));
});

@@ -112,4 +112,4 @@ it("can derive path m/0/2147483647'/1/2147483646'", () => {

const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Secp256k1, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("637807030d55d01f9a0cb3a7839515d796bd07706386a6eddf06cc29a65a0e29"));
expect(derived.privkey).toEqual(encoding_1.fromHex("f1c7c871a54a804afe328b4c83a1c33b8e5ff48f5087273f04efa83b247d6a2d"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("637807030d55d01f9a0cb3a7839515d796bd07706386a6eddf06cc29a65a0e29"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("f1c7c871a54a804afe328b4c83a1c33b8e5ff48f5087273f04efa83b247d6a2d"));
});

@@ -125,4 +125,4 @@ it("can derive path m/0/2147483647'/1/2147483646'/2", () => {

const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Secp256k1, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("9452b549be8cea3ecb7a84bec10dcfd94afe4d129ebfd3b3cb58eedf394ed271"));
expect(derived.privkey).toEqual(encoding_1.fromHex("bb7d39bdb83ecf58f2fd82b6d918341cbef428661ef01ab97c28a4842125ac23"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("9452b549be8cea3ecb7a84bec10dcfd94afe4d129ebfd3b3cb58eedf394ed271"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("bb7d39bdb83ecf58f2fd82b6d918341cbef428661ef01ab97c28a4842125ac23"));
});

@@ -132,8 +132,8 @@ });

// https://github.com/satoshilabs/slips/blob/master/slip-0010.md#test-vector-1-for-ed25519
const seed = encoding_1.fromHex("000102030405060708090a0b0c0d0e0f");
const seed = (0, encoding_1.fromHex)("000102030405060708090a0b0c0d0e0f");
it("can derive path m", () => {
const path = [];
const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Ed25519, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("90046a93de5380a72b5e45010748567d5ea02bbf6522f979e05c0d8d8ca9fffb"));
expect(derived.privkey).toEqual(encoding_1.fromHex("2b4be7f19ee27bbf30c667b642d5f4aa69fd169872f8fc3059c08ebae2eb19e7"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("90046a93de5380a72b5e45010748567d5ea02bbf6522f979e05c0d8d8ca9fffb"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("2b4be7f19ee27bbf30c667b642d5f4aa69fd169872f8fc3059c08ebae2eb19e7"));
});

@@ -143,4 +143,4 @@ it("can derive path m/0'", () => {

const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Ed25519, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("8b59aa11380b624e81507a27fedda59fea6d0b779a778918a2fd3590e16e9c69"));
expect(derived.privkey).toEqual(encoding_1.fromHex("68e0fe46dfb67e368c75379acec591dad19df3cde26e63b93a8e704f1dade7a3"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("8b59aa11380b624e81507a27fedda59fea6d0b779a778918a2fd3590e16e9c69"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("68e0fe46dfb67e368c75379acec591dad19df3cde26e63b93a8e704f1dade7a3"));
});

@@ -150,4 +150,4 @@ it("can derive path m/0'/1'", () => {

const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Ed25519, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("a320425f77d1b5c2505a6b1b27382b37368ee640e3557c315416801243552f14"));
expect(derived.privkey).toEqual(encoding_1.fromHex("b1d0bad404bf35da785a64ca1ac54b2617211d2777696fbffaf208f746ae84f2"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("a320425f77d1b5c2505a6b1b27382b37368ee640e3557c315416801243552f14"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("b1d0bad404bf35da785a64ca1ac54b2617211d2777696fbffaf208f746ae84f2"));
});

@@ -161,4 +161,4 @@ it("can derive path m/0'/1'/2'", () => {

const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Ed25519, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("2e69929e00b5ab250f49c3fb1c12f252de4fed2c1db88387094a0f8c4c9ccd6c"));
expect(derived.privkey).toEqual(encoding_1.fromHex("92a5b23c0b8a99e37d07df3fb9966917f5d06e02ddbd909c7e184371463e9fc9"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("2e69929e00b5ab250f49c3fb1c12f252de4fed2c1db88387094a0f8c4c9ccd6c"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("92a5b23c0b8a99e37d07df3fb9966917f5d06e02ddbd909c7e184371463e9fc9"));
});

@@ -173,4 +173,4 @@ it("can derive path m/0'/1'/2'/2'", () => {

const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Ed25519, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("8f6d87f93d750e0efccda017d662a1b31a266e4a6f5993b15f5c1f07f74dd5cc"));
expect(derived.privkey).toEqual(encoding_1.fromHex("30d1dc7e5fc04c31219ab25a27ae00b50f6fd66622f6e9c913253d6511d1e662"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("8f6d87f93d750e0efccda017d662a1b31a266e4a6f5993b15f5c1f07f74dd5cc"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("30d1dc7e5fc04c31219ab25a27ae00b50f6fd66622f6e9c913253d6511d1e662"));
});

@@ -186,4 +186,4 @@ it("can derive path m/0'/1'/2'/2'/1000000000'", () => {

const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Ed25519, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("68789923a0cac2cd5a29172a475fe9e0fb14cd6adb5ad98a3fa70333e7afa230"));
expect(derived.privkey).toEqual(encoding_1.fromHex("8f94d394a8e8fd6b1bc2f3f49f5c47e385281d5c17e65324b0f62483e37e8793"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("68789923a0cac2cd5a29172a475fe9e0fb14cd6adb5ad98a3fa70333e7afa230"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("8f94d394a8e8fd6b1bc2f3f49f5c47e385281d5c17e65324b0f62483e37e8793"));
});

@@ -193,8 +193,8 @@ });

// https://github.com/satoshilabs/slips/blob/master/slip-0010.md#test-vector-2-for-ed25519
const seed = encoding_1.fromHex("fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542");
const seed = (0, encoding_1.fromHex)("fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542");
it("can derive path m", () => {
const path = [];
const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Ed25519, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("ef70a74db9c3a5af931b5fe73ed8e1a53464133654fd55e7a66f8570b8e33c3b"));
expect(derived.privkey).toEqual(encoding_1.fromHex("171cb88b1b3c1db25add599712e36245d75bc65a1a5c9e18d76f9f2b1eab4012"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("ef70a74db9c3a5af931b5fe73ed8e1a53464133654fd55e7a66f8570b8e33c3b"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("171cb88b1b3c1db25add599712e36245d75bc65a1a5c9e18d76f9f2b1eab4012"));
});

@@ -204,4 +204,4 @@ it("can derive path m/0'", () => {

const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Ed25519, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("0b78a3226f915c082bf118f83618a618ab6dec793752624cbeb622acb562862d"));
expect(derived.privkey).toEqual(encoding_1.fromHex("1559eb2bbec5790b0c65d8693e4d0875b1747f4970ae8b650486ed7470845635"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("0b78a3226f915c082bf118f83618a618ab6dec793752624cbeb622acb562862d"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("1559eb2bbec5790b0c65d8693e4d0875b1747f4970ae8b650486ed7470845635"));
});

@@ -211,4 +211,4 @@ it("can derive path m/0'/2147483647'", () => {

const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Ed25519, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("138f0b2551bcafeca6ff2aa88ba8ed0ed8de070841f0c4ef0165df8181eaad7f"));
expect(derived.privkey).toEqual(encoding_1.fromHex("ea4f5bfe8694d8bb74b7b59404632fd5968b774ed545e810de9c32a4fb4192f4"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("138f0b2551bcafeca6ff2aa88ba8ed0ed8de070841f0c4ef0165df8181eaad7f"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("ea4f5bfe8694d8bb74b7b59404632fd5968b774ed545e810de9c32a4fb4192f4"));
});

@@ -222,4 +222,4 @@ it("can derive path m/0'/2147483647'/1'", () => {

const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Ed25519, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("73bd9fff1cfbde33a1b846c27085f711c0fe2d66fd32e139d3ebc28e5a4a6b90"));
expect(derived.privkey).toEqual(encoding_1.fromHex("3757c7577170179c7868353ada796c839135b3d30554bbb74a4b1e4a5a58505c"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("73bd9fff1cfbde33a1b846c27085f711c0fe2d66fd32e139d3ebc28e5a4a6b90"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("3757c7577170179c7868353ada796c839135b3d30554bbb74a4b1e4a5a58505c"));
});

@@ -234,4 +234,4 @@ it("can derive path m/0'/2147483647'/1'/2147483646'", () => {

const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Ed25519, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("0902fe8a29f9140480a00ef244bd183e8a13288e4412d8389d140aac1794825a"));
expect(derived.privkey).toEqual(encoding_1.fromHex("5837736c89570de861ebc173b1086da4f505d4adb387c6a1b1342d5e4ac9ec72"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("0902fe8a29f9140480a00ef244bd183e8a13288e4412d8389d140aac1794825a"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("5837736c89570de861ebc173b1086da4f505d4adb387c6a1b1342d5e4ac9ec72"));
});

@@ -247,4 +247,4 @@ it("can derive path m/0'/2147483647'/1'/2147483646'/2'", () => {

const derived = slip10_1.Slip10.derivePath(slip10_1.Slip10Curve.Ed25519, seed, path);
expect(derived.chainCode).toEqual(encoding_1.fromHex("5d70af781f3a37b829f0d060924d5e960bdc02e85423494afc0b1a41bbe196d4"));
expect(derived.privkey).toEqual(encoding_1.fromHex("551d333177df541ad876a60ea71f00447931c0a9da16f227c11ea080d7391b8d"));
expect(derived.chainCode).toEqual((0, encoding_1.fromHex)("5d70af781f3a37b829f0d060924d5e960bdc02e85423494afc0b1a41bbe196d4"));
expect(derived.privkey).toEqual((0, encoding_1.fromHex)("551d333177df541ad876a60ea71f00447931c0a9da16f227c11ea080d7391b8d"));
});

@@ -255,23 +255,23 @@ });

// See https://github.com/bitcoin/bips/blob/master/bip-0032/derivation.png from BIP32
expect(slip10_1.pathToString([])).toEqual("m");
expect((0, slip10_1.pathToString)([])).toEqual("m");
});
it("works for normal components", () => {
const one = slip10_1.Slip10RawIndex.normal(1);
expect(slip10_1.pathToString([one])).toEqual("m/1");
expect(slip10_1.pathToString([one, one])).toEqual("m/1/1");
expect(slip10_1.pathToString([one, one, one])).toEqual("m/1/1/1");
expect((0, slip10_1.pathToString)([one])).toEqual("m/1");
expect((0, slip10_1.pathToString)([one, one])).toEqual("m/1/1");
expect((0, slip10_1.pathToString)([one, one, one])).toEqual("m/1/1/1");
const min = slip10_1.Slip10RawIndex.normal(0);
expect(slip10_1.pathToString([min])).toEqual("m/0");
expect((0, slip10_1.pathToString)([min])).toEqual("m/0");
const max = slip10_1.Slip10RawIndex.normal(2 ** 31 - 1);
expect(slip10_1.pathToString([max])).toEqual("m/2147483647");
expect((0, slip10_1.pathToString)([max])).toEqual("m/2147483647");
});
it("works for hardened components", () => {
const one = slip10_1.Slip10RawIndex.hardened(1);
expect(slip10_1.pathToString([one])).toEqual("m/1'");
expect(slip10_1.pathToString([one, one])).toEqual("m/1'/1'");
expect(slip10_1.pathToString([one, one, one])).toEqual("m/1'/1'/1'");
expect((0, slip10_1.pathToString)([one])).toEqual("m/1'");
expect((0, slip10_1.pathToString)([one, one])).toEqual("m/1'/1'");
expect((0, slip10_1.pathToString)([one, one, one])).toEqual("m/1'/1'/1'");
const min = slip10_1.Slip10RawIndex.hardened(0);
expect(slip10_1.pathToString([min])).toEqual("m/0'");
expect((0, slip10_1.pathToString)([min])).toEqual("m/0'");
const max = slip10_1.Slip10RawIndex.hardened(2 ** 31 - 1);
expect(slip10_1.pathToString([max])).toEqual("m/2147483647'");
expect((0, slip10_1.pathToString)([max])).toEqual("m/2147483647'");
});

@@ -281,3 +281,3 @@ it("works for mixed components", () => {

const two = slip10_1.Slip10RawIndex.hardened(2);
expect(slip10_1.pathToString([one, two, two, one])).toEqual("m/1/2'/2'/1");
expect((0, slip10_1.pathToString)([one, two, two, one])).toEqual("m/1/2'/2'/1");
});

@@ -288,44 +288,44 @@ });

// See https://github.com/bitcoin/bips/blob/master/bip-0032/derivation.png from BIP32
expect(slip10_1.stringToPath("m")).toEqual([]);
expect((0, slip10_1.stringToPath)("m")).toEqual([]);
});
it("throws for broken start", () => {
expect(() => slip10_1.stringToPath("")).toThrowError(/must start with 'm'/);
expect(() => slip10_1.stringToPath("M")).toThrowError(/must start with 'm'/);
expect(() => slip10_1.stringToPath("/1/1")).toThrowError(/must start with 'm'/);
expect(() => (0, slip10_1.stringToPath)("")).toThrowError(/must start with 'm'/);
expect(() => (0, slip10_1.stringToPath)("M")).toThrowError(/must start with 'm'/);
expect(() => (0, slip10_1.stringToPath)("/1/1")).toThrowError(/must start with 'm'/);
});
it("works for normal components", () => {
const one = slip10_1.Slip10RawIndex.normal(1);
expect(slip10_1.stringToPath("m/1")).toEqual([one]);
expect(slip10_1.stringToPath("m/1/1")).toEqual([one, one]);
expect(slip10_1.stringToPath("m/1/1/1")).toEqual([one, one, one]);
expect((0, slip10_1.stringToPath)("m/1")).toEqual([one]);
expect((0, slip10_1.stringToPath)("m/1/1")).toEqual([one, one]);
expect((0, slip10_1.stringToPath)("m/1/1/1")).toEqual([one, one, one]);
const min = slip10_1.Slip10RawIndex.normal(0);
expect(slip10_1.stringToPath("m/0")).toEqual([min]);
expect((0, slip10_1.stringToPath)("m/0")).toEqual([min]);
const max = slip10_1.Slip10RawIndex.normal(2 ** 31 - 1);
expect(slip10_1.stringToPath("m/2147483647")).toEqual([max]);
expect((0, slip10_1.stringToPath)("m/2147483647")).toEqual([max]);
});
it("errors for syntax error in component", () => {
expect(() => slip10_1.stringToPath("m/ 1/1/1")).toThrowError(/syntax error/i);
expect(() => slip10_1.stringToPath("m/-1/1/1")).toThrowError(/syntax error/i);
expect(() => slip10_1.stringToPath("m//1/1")).toThrowError(/syntax error/i);
expect(() => slip10_1.stringToPath("m/1*/1/1")).toThrowError(/syntax error/i);
expect(() => slip10_1.stringToPath("m/1/1/1 ")).toThrowError(/syntax error/i);
expect(() => slip10_1.stringToPath("m/1''/1/1")).toThrowError(/syntax error/i);
expect(() => slip10_1.stringToPath("m/1 '/1/1")).toThrowError(/syntax error/i);
expect(() => slip10_1.stringToPath("m/'/1/1")).toThrowError(/syntax error/i);
expect(() => slip10_1.stringToPath('m/1"/1/1')).toThrowError(/syntax error/i);
expect(() => (0, slip10_1.stringToPath)("m/ 1/1/1")).toThrowError(/syntax error/i);
expect(() => (0, slip10_1.stringToPath)("m/-1/1/1")).toThrowError(/syntax error/i);
expect(() => (0, slip10_1.stringToPath)("m//1/1")).toThrowError(/syntax error/i);
expect(() => (0, slip10_1.stringToPath)("m/1*/1/1")).toThrowError(/syntax error/i);
expect(() => (0, slip10_1.stringToPath)("m/1/1/1 ")).toThrowError(/syntax error/i);
expect(() => (0, slip10_1.stringToPath)("m/1''/1/1")).toThrowError(/syntax error/i);
expect(() => (0, slip10_1.stringToPath)("m/1 '/1/1")).toThrowError(/syntax error/i);
expect(() => (0, slip10_1.stringToPath)("m/'/1/1")).toThrowError(/syntax error/i);
expect(() => (0, slip10_1.stringToPath)('m/1"/1/1')).toThrowError(/syntax error/i);
});
it("errors for value too high", () => {
expect(() => slip10_1.stringToPath("m/2147483648/1/1")).toThrowError(/value too high/i);
expect(() => slip10_1.stringToPath("m/1/9007199254740991/1")).toThrowError(/value too high/i);
expect(() => slip10_1.stringToPath("m/1/1/9007199254740992")).toThrowError(/not in int53 range/i);
expect(() => (0, slip10_1.stringToPath)("m/2147483648/1/1")).toThrowError(/value too high/i);
expect(() => (0, slip10_1.stringToPath)("m/1/9007199254740991/1")).toThrowError(/value too high/i);
expect(() => (0, slip10_1.stringToPath)("m/1/1/9007199254740992")).toThrowError(/not in int53 range/i);
});
it("works for hardened components", () => {
const one = slip10_1.Slip10RawIndex.hardened(1);
expect(slip10_1.stringToPath("m/1'")).toEqual([one]);
expect(slip10_1.stringToPath("m/1'/1'")).toEqual([one, one]);
expect(slip10_1.stringToPath("m/1'/1'/1'")).toEqual([one, one, one]);
expect((0, slip10_1.stringToPath)("m/1'")).toEqual([one]);
expect((0, slip10_1.stringToPath)("m/1'/1'")).toEqual([one, one]);
expect((0, slip10_1.stringToPath)("m/1'/1'/1'")).toEqual([one, one, one]);
const min = slip10_1.Slip10RawIndex.hardened(0);
expect(slip10_1.stringToPath("m/0'")).toEqual([min]);
expect((0, slip10_1.stringToPath)("m/0'")).toEqual([min]);
const max = slip10_1.Slip10RawIndex.hardened(2 ** 31 - 1);
expect(slip10_1.stringToPath("m/2147483647'")).toEqual([max]);
expect((0, slip10_1.stringToPath)("m/2147483647'")).toEqual([max]);
});

@@ -335,3 +335,3 @@ it("works for mixed components", () => {

const two = slip10_1.Slip10RawIndex.hardened(2);
expect(slip10_1.stringToPath("m/1/2'/2'/1")).toEqual([one, two, two, one]);
expect((0, slip10_1.stringToPath)("m/1/2'/2'/1")).toEqual([one, two, two, one]);
});

@@ -338,0 +338,0 @@ });

{
"name": "@cosmjs/crypto",
"version": "0.26.6",
"version": "0.26.8",
"description": "Cryptography resources for blockchain projects",

@@ -32,3 +32,3 @@ "contributors": [

"format-text": "prettier --write \"./*.md\"",
"test-node": "node --require esm jasmine-testrunner.js",
"test-node": "yarn node jasmine-testrunner.js",
"test-edge": "yarn pack-web && karma start --single-run --browsers Edge",

@@ -45,16 +45,13 @@ "test-firefox": "yarn pack-web && karma start --single-run --browsers Firefox",

"dependencies": {
"@cosmjs/encoding": "0.26.6",
"@cosmjs/math": "0.26.6",
"@cosmjs/utils": "0.26.6",
"bip39": "^3.0.2",
"bn.js": "^4.11.8",
"@cosmjs/encoding": "0.26.8",
"@cosmjs/math": "0.26.8",
"@cosmjs/utils": "0.26.8",
"@noble/hashes": "^1",
"bn.js": "^5.2.0",
"elliptic": "^6.5.3",
"js-sha3": "^0.8.0",
"libsodium-wrappers": "^0.7.6",
"ripemd160": "^2.0.2",
"sha.js": "^2.4.11"
"libsodium-wrappers": "^0.7.6"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@types/bn.js": "^4.11.6",
"@types/bn.js": "^5",
"@types/elliptic": "^6.4.12",

@@ -68,6 +65,4 @@ "@types/eslint-plugin-prettier": "^3",

"@types/node": "^15.0.1",
"@types/ripemd160": "^2.0.0",
"@types/sha.js": "^2.4.0",
"@typescript-eslint/eslint-plugin": "^4.28",
"@typescript-eslint/parser": "^4.28",
"@typescript-eslint/eslint-plugin": "^5.13.0",
"@typescript-eslint/parser": "^5.13.0",
"buffer": "^6.0.3",

@@ -82,6 +77,5 @@ "eslint": "^7.5",

"glob": "^7.1.6",
"jasmine": "^3.8",
"jasmine-core": "^3.7.1",
"jasmine": "^3.99",
"jasmine-spec-reporter": "^6",
"karma": "^6.1.1",
"karma": "^6.3.14",
"karma-chrome-launcher": "^3.1.0",

@@ -95,6 +89,5 @@ "karma-firefox-launcher": "^2.1.0",

"source-map-support": "^0.5.19",
"stream-browserify": "^3.0.0",
"ts-node": "^8",
"typedoc": "^0.21",
"typescript": "~4.3",
"typedoc": "^0.22",
"typescript": "~4.4",
"webpack": "^5.32.0",

@@ -101,0 +94,0 @@ "webpack-cli": "^4.6.0"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc