@totemsdk/core 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/dist/Streamable.d.ts +268 -0
  2. package/dist/Streamable.js +416 -0
  3. package/dist/adapters/index.d.ts +190 -0
  4. package/dist/adapters/index.js +107 -0
  5. package/dist/adapters/types.d.ts +149 -0
  6. package/dist/adapters/types.js +67 -0
  7. package/dist/binio.d.ts +9 -0
  8. package/dist/binio.js +30 -0
  9. package/dist/bip39.d.ts +91 -0
  10. package/dist/bip39.js +417 -0
  11. package/dist/derive.d.ts +2 -0
  12. package/dist/derive.js +9 -0
  13. package/dist/index.d.ts +30 -0
  14. package/dist/index.js +53 -0
  15. package/dist/javaStreamables.d.ts +233 -0
  16. package/dist/javaStreamables.js +332 -0
  17. package/dist/lease/LeaseMonitor.d.ts +44 -0
  18. package/dist/lease/LeaseMonitor.js +107 -0
  19. package/dist/lease/LeaseStore.d.ts +57 -0
  20. package/dist/lease/LeaseStore.js +144 -0
  21. package/dist/lease/WatermarkStore.d.ts +61 -0
  22. package/dist/lease/WatermarkStore.js +202 -0
  23. package/dist/lease/index.d.ts +14 -0
  24. package/dist/lease/index.js +13 -0
  25. package/dist/lease-client.d.ts +31 -0
  26. package/dist/lease-client.js +39 -0
  27. package/dist/minima32.d.ts +18 -0
  28. package/dist/minima32.js +112 -0
  29. package/dist/minimaWireSerializer.d.ts +60 -0
  30. package/dist/minimaWireSerializer.js +71 -0
  31. package/dist/mmr.d.ts +156 -0
  32. package/dist/mmr.js +342 -0
  33. package/dist/mx.d.ts +1 -0
  34. package/dist/mx.js +1 -0
  35. package/dist/params.d.ts +29 -0
  36. package/dist/params.js +16 -0
  37. package/dist/script.d.ts +7 -0
  38. package/dist/script.js +22 -0
  39. package/dist/scripts/contract-helpers.d.ts +252 -0
  40. package/dist/scripts/contract-helpers.js +394 -0
  41. package/dist/scripts/dapp-types.d.ts +119 -0
  42. package/dist/scripts/dapp-types.js +72 -0
  43. package/dist/scripts/index.d.ts +4 -0
  44. package/dist/scripts/index.js +4 -0
  45. package/dist/scripts/types.d.ts +81 -0
  46. package/dist/scripts/types.js +145 -0
  47. package/dist/scripts/witness-serializer.d.ts +29 -0
  48. package/dist/scripts/witness-serializer.js +288 -0
  49. package/dist/transaction.d.ts +106 -0
  50. package/dist/transaction.js +284 -0
  51. package/dist/treekey.d.ts +383 -0
  52. package/dist/treekey.js +762 -0
  53. package/dist/tx/TransactionLifecycle.d.ts +55 -0
  54. package/dist/tx/TransactionLifecycle.js +189 -0
  55. package/dist/tx/TransactionReceiptStore.d.ts +36 -0
  56. package/dist/tx/TransactionReceiptStore.js +85 -0
  57. package/dist/tx/TransactionService.d.ts +50 -0
  58. package/dist/tx/TransactionService.js +178 -0
  59. package/dist/tx/index.d.ts +13 -0
  60. package/dist/tx/index.js +12 -0
  61. package/dist/tx/types.d.ts +114 -0
  62. package/dist/tx/types.js +5 -0
  63. package/dist/util.d.ts +1 -0
  64. package/dist/util.js +1 -0
  65. package/dist/utils.d.ts +8 -0
  66. package/dist/utils.js +35 -0
  67. package/dist/verify.d.ts +18 -0
  68. package/dist/verify.js +162 -0
  69. package/dist/version.d.ts +12 -0
  70. package/dist/version.js +12 -0
  71. package/dist/wots.d.ts +232 -0
  72. package/dist/wots.js +538 -0
  73. package/package.json +65 -0
  74. package/src/Streamable.d.ts +265 -0
  75. package/src/Streamable.js +431 -0
  76. package/src/Streamable.ts +567 -0
  77. package/src/__tests__/Streamable.parity.test.ts +422 -0
  78. package/src/__tests__/perAddressDerivation.parity.test.ts +152 -0
  79. package/src/__tests__/wots-parity.test.ts +289 -0
  80. package/src/adapters/index.d.ts +190 -0
  81. package/src/adapters/index.js +117 -0
  82. package/src/adapters/index.ts +301 -0
  83. package/src/adapters/types.ts +235 -0
  84. package/src/addr.oracle.test.ts +25 -0
  85. package/src/address.test.ts +55 -0
  86. package/src/binio.ts +21 -0
  87. package/src/bip39.d.ts +91 -0
  88. package/src/bip39.js +427 -0
  89. package/src/bip39.ts +432 -0
  90. package/src/derive.d.ts +2 -0
  91. package/src/derive.js +13 -0
  92. package/src/derive.ts +11 -0
  93. package/src/index.d.ts +26 -0
  94. package/src/index.js +128 -0
  95. package/src/index.test.ts +5 -0
  96. package/src/index.ts +206 -0
  97. package/src/javaStreamables.d.ts +233 -0
  98. package/src/javaStreamables.js +328 -0
  99. package/src/javaStreamables.ts +403 -0
  100. package/src/lease/LeaseMonitor.d.ts +44 -0
  101. package/src/lease/LeaseMonitor.js +111 -0
  102. package/src/lease/LeaseMonitor.ts +157 -0
  103. package/src/lease/LeaseStore.d.ts +57 -0
  104. package/src/lease/LeaseStore.js +148 -0
  105. package/src/lease/LeaseStore.ts +203 -0
  106. package/src/lease/WatermarkStore.d.ts +61 -0
  107. package/src/lease/WatermarkStore.js +206 -0
  108. package/src/lease/WatermarkStore.ts +270 -0
  109. package/src/lease/index.d.ts +14 -0
  110. package/src/lease/index.js +22 -0
  111. package/src/lease/index.ts +41 -0
  112. package/src/lease-client.d.ts +31 -0
  113. package/src/lease-client.js +44 -0
  114. package/src/lease-client.ts +69 -0
  115. package/src/minima32.d.ts +10 -0
  116. package/src/minima32.js +113 -0
  117. package/src/minima32.test.ts +11 -0
  118. package/src/minima32.ts +127 -0
  119. package/src/minimaWireSerializer.d.ts +189 -0
  120. package/src/minimaWireSerializer.js +311 -0
  121. package/src/minimaWireSerializer.test.ts +466 -0
  122. package/src/minimaWireSerializer.ts +117 -0
  123. package/src/mmr.d.ts +153 -0
  124. package/src/mmr.js +351 -0
  125. package/src/mmr.oracle.test.ts +28 -0
  126. package/src/mmr.ts +429 -0
  127. package/src/mx.test.ts +25 -0
  128. package/src/mx.ts +1 -0
  129. package/src/params.d.ts +29 -0
  130. package/src/params.d.ts.map +1 -0
  131. package/src/params.js +20 -0
  132. package/src/params.js.map +1 -0
  133. package/src/params.ts +44 -0
  134. package/src/script.d.ts +7 -0
  135. package/src/script.js +27 -0
  136. package/src/script.ts +24 -0
  137. package/src/scripts/contract-helpers.ts +609 -0
  138. package/src/scripts/dapp-types.ts +240 -0
  139. package/src/scripts/index.ts +22 -0
  140. package/src/scripts/types.ts +247 -0
  141. package/src/scripts/witness-serializer.ts +384 -0
  142. package/src/transaction.ts +430 -0
  143. package/src/treekey.d.ts +383 -0
  144. package/src/treekey.js +778 -0
  145. package/src/treekey.parity.test.ts +459 -0
  146. package/src/treekey.ts +979 -0
  147. package/src/tx/TransactionLifecycle.d.ts +55 -0
  148. package/src/tx/TransactionLifecycle.js +188 -0
  149. package/src/tx/TransactionLifecycle.ts +280 -0
  150. package/src/tx/TransactionReceiptStore.d.ts +36 -0
  151. package/src/tx/TransactionReceiptStore.js +89 -0
  152. package/src/tx/TransactionReceiptStore.ts +112 -0
  153. package/src/tx/TransactionService.d.ts +31 -0
  154. package/src/tx/TransactionService.js +140 -0
  155. package/src/tx/TransactionService.ts +250 -0
  156. package/src/tx/index.d.ts +13 -0
  157. package/src/tx/index.js +20 -0
  158. package/src/tx/index.ts +44 -0
  159. package/src/tx/types.d.ts +80 -0
  160. package/src/tx/types.js +6 -0
  161. package/src/tx/types.ts +127 -0
  162. package/src/util.d.ts +1 -0
  163. package/src/util.js +5 -0
  164. package/src/util.ts +1 -0
  165. package/src/utils.d.ts +8 -0
  166. package/src/utils.js +42 -0
  167. package/src/utils.ts +38 -0
  168. package/src/verify.ts +209 -0
  169. package/src/version.ts +13 -0
  170. package/src/wots.d.ts +224 -0
  171. package/src/wots.d.ts.map +1 -0
  172. package/src/wots.js +559 -0
  173. package/src/wots.js.map +1 -0
  174. package/src/wots.ts +636 -0
  175. package/test-vectors.json +45 -0
package/src/bip39.ts ADDED
@@ -0,0 +1,432 @@
1
+ /**
2
+ * Minima-Compatible BIP39 Seed Phrase Handling
3
+ *
4
+ * IMPORTANT: This is NOT standard BIP39!
5
+ * Minima uses the BIP39 English word list for human-friendly phrases,
6
+ * but does NOT use PBKDF2, passphrase salt, or checksum validation.
7
+ *
8
+ * Seed derivation is simply: SHA3-256(phrase_bytes)
9
+ *
10
+ * Matches BIP39.java behavior exactly:
11
+ * - cleanSeedPhrase(): Normalizes input with prefix matching
12
+ * - convertStringToSeed(): Hashes phrase bytes with SHA3-256
13
+ */
14
+
15
+ import { sha3_256 } from '@noble/hashes/sha3';
16
+
17
+ /**
18
+ * Official BIP39 English word list (2048 words)
19
+ * From https://github.com/bitcoin/bips/blob/master/bip-0039/english.txt
20
+ */
21
+ export const WORD_LIST: readonly string[] = [
22
+ "abandon", "ability", "able", "about", "above", "absent", "absorb", "abstract",
23
+ "absurd", "abuse", "access", "accident", "account", "accuse", "achieve", "acid",
24
+ "acoustic", "acquire", "across", "act", "action", "actor", "actress", "actual",
25
+ "adapt", "add", "addict", "address", "adjust", "admit", "adult", "advance",
26
+ "advice", "aerobic", "affair", "afford", "afraid", "again", "age", "agent",
27
+ "agree", "ahead", "aim", "air", "airport", "aisle", "alarm", "album",
28
+ "alcohol", "alert", "alien", "all", "alley", "allow", "almost", "alone",
29
+ "alpha", "already", "also", "alter", "always", "amateur", "amazing", "among",
30
+ "amount", "amused", "analyst", "anchor", "ancient", "anger", "angle", "angry",
31
+ "animal", "ankle", "announce", "annual", "another", "answer", "antenna", "antique",
32
+ "anxiety", "any", "apart", "apology", "appear", "apple", "approve", "april",
33
+ "arch", "arctic", "area", "arena", "argue", "arm", "armed", "armor",
34
+ "army", "around", "arrange", "arrest", "arrive", "arrow", "art", "artefact",
35
+ "artist", "artwork", "ask", "aspect", "assault", "asset", "assist", "assume",
36
+ "asthma", "athlete", "atom", "attack", "attend", "attitude", "attract", "auction",
37
+ "audit", "august", "aunt", "author", "auto", "autumn", "average", "avocado",
38
+ "avoid", "awake", "aware", "away", "awesome", "awful", "awkward", "axis",
39
+ "baby", "bachelor", "bacon", "badge", "bag", "balance", "balcony", "ball",
40
+ "bamboo", "banana", "banner", "bar", "barely", "bargain", "barrel", "base",
41
+ "basic", "basket", "battle", "beach", "bean", "beauty", "because", "become",
42
+ "beef", "before", "begin", "behave", "behind", "believe", "below", "belt",
43
+ "bench", "benefit", "best", "betray", "better", "between", "beyond", "bicycle",
44
+ "bid", "bike", "bind", "biology", "bird", "birth", "bitter", "black",
45
+ "blade", "blame", "blanket", "blast", "bleak", "bless", "blind", "blood",
46
+ "blossom", "blouse", "blue", "blur", "blush", "board", "boat", "body",
47
+ "boil", "bomb", "bone", "bonus", "book", "boost", "border", "boring",
48
+ "borrow", "boss", "bottom", "bounce", "box", "boy", "bracket", "brain",
49
+ "brand", "brass", "brave", "bread", "breeze", "brick", "bridge", "brief",
50
+ "bright", "bring", "brisk", "broccoli", "broken", "bronze", "broom", "brother",
51
+ "brown", "brush", "bubble", "buddy", "budget", "buffalo", "build", "bulb",
52
+ "bulk", "bullet", "bundle", "bunker", "burden", "burger", "burst", "bus",
53
+ "business", "busy", "butter", "buyer", "buzz", "cabbage", "cabin", "cable",
54
+ "cactus", "cage", "cake", "call", "calm", "camera", "camp", "can",
55
+ "canal", "cancel", "candy", "cannon", "canoe", "canvas", "canyon", "capable",
56
+ "capital", "captain", "car", "carbon", "card", "cargo", "carpet", "carry",
57
+ "cart", "case", "cash", "casino", "castle", "casual", "cat", "catalog",
58
+ "catch", "category", "cattle", "caught", "cause", "caution", "cave", "ceiling",
59
+ "celery", "cement", "census", "century", "cereal", "certain", "chair", "chalk",
60
+ "champion", "change", "chaos", "chapter", "charge", "chase", "chat", "cheap",
61
+ "check", "cheese", "chef", "cherry", "chest", "chicken", "chief", "child",
62
+ "chimney", "choice", "choose", "chronic", "chuckle", "chunk", "churn", "cigar",
63
+ "cinnamon", "circle", "citizen", "city", "civil", "claim", "clap", "clarify",
64
+ "claw", "clay", "clean", "clerk", "clever", "click", "client", "cliff",
65
+ "climb", "clinic", "clip", "clock", "clog", "close", "cloth", "cloud",
66
+ "clown", "club", "clump", "cluster", "clutch", "coach", "coast", "coconut",
67
+ "code", "coffee", "coil", "coin", "collect", "color", "column", "combine",
68
+ "come", "comfort", "comic", "common", "company", "concert", "conduct", "confirm",
69
+ "congress", "connect", "consider", "control", "convince", "cook", "cool", "copper",
70
+ "copy", "coral", "core", "corn", "correct", "cost", "cotton", "couch",
71
+ "country", "couple", "course", "cousin", "cover", "coyote", "crack", "cradle",
72
+ "craft", "cram", "crane", "crash", "crater", "crawl", "crazy", "cream",
73
+ "credit", "creek", "crew", "cricket", "crime", "crisp", "critic", "crop",
74
+ "cross", "crouch", "crowd", "crucial", "cruel", "cruise", "crumble", "crunch",
75
+ "crush", "cry", "crystal", "cube", "culture", "cup", "cupboard", "curious",
76
+ "current", "curtain", "curve", "cushion", "custom", "cute", "cycle", "dad",
77
+ "damage", "damp", "dance", "danger", "daring", "dash", "daughter", "dawn",
78
+ "day", "deal", "debate", "debris", "decade", "december", "decide", "decline",
79
+ "decorate", "decrease", "deer", "defense", "define", "defy", "degree", "delay",
80
+ "deliver", "demand", "demise", "denial", "dentist", "deny", "depart", "depend",
81
+ "deposit", "depth", "deputy", "derive", "describe", "desert", "design", "desk",
82
+ "despair", "destroy", "detail", "detect", "develop", "device", "devote", "diagram",
83
+ "dial", "diamond", "diary", "dice", "diesel", "diet", "differ", "digital",
84
+ "dignity", "dilemma", "dinner", "dinosaur", "direct", "dirt", "disagree", "discover",
85
+ "disease", "dish", "dismiss", "disorder", "display", "distance", "divert", "divide",
86
+ "divorce", "dizzy", "doctor", "document", "dog", "doll", "dolphin", "domain",
87
+ "donate", "donkey", "donor", "door", "dose", "double", "dove", "draft",
88
+ "dragon", "drama", "drastic", "draw", "dream", "dress", "drift", "drill",
89
+ "drink", "drip", "drive", "drop", "drum", "dry", "duck", "dumb",
90
+ "dune", "during", "dust", "dutch", "duty", "dwarf", "dynamic", "eager",
91
+ "eagle", "early", "earn", "earth", "easily", "east", "easy", "echo",
92
+ "ecology", "economy", "edge", "edit", "educate", "effort", "egg", "eight",
93
+ "either", "elbow", "elder", "electric", "elegant", "element", "elephant", "elevator",
94
+ "elite", "else", "embark", "embody", "embrace", "emerge", "emotion", "employ",
95
+ "empower", "empty", "enable", "enact", "end", "endless", "endorse", "enemy",
96
+ "energy", "enforce", "engage", "engine", "enhance", "enjoy", "enlist", "enough",
97
+ "enrich", "enroll", "ensure", "enter", "entire", "entry", "envelope", "episode",
98
+ "equal", "equip", "era", "erase", "erode", "erosion", "error", "erupt",
99
+ "escape", "essay", "essence", "estate", "eternal", "ethics", "evidence", "evil",
100
+ "evoke", "evolve", "exact", "example", "excess", "exchange", "excite", "exclude",
101
+ "excuse", "execute", "exercise", "exhaust", "exhibit", "exile", "exist", "exit",
102
+ "exotic", "expand", "expect", "expire", "explain", "expose", "express", "extend",
103
+ "extra", "eye", "eyebrow", "fabric", "face", "faculty", "fade", "faint",
104
+ "faith", "fall", "false", "fame", "family", "famous", "fan", "fancy",
105
+ "fantasy", "farm", "fashion", "fat", "fatal", "father", "fatigue", "fault",
106
+ "favorite", "feature", "february", "federal", "fee", "feed", "feel", "female",
107
+ "fence", "festival", "fetch", "fever", "few", "fiber", "fiction", "field",
108
+ "figure", "file", "film", "filter", "final", "find", "fine", "finger",
109
+ "finish", "fire", "firm", "first", "fiscal", "fish", "fit", "fitness",
110
+ "fix", "flag", "flame", "flash", "flat", "flavor", "flee", "flight",
111
+ "flip", "float", "flock", "floor", "flower", "fluid", "flush", "fly",
112
+ "foam", "focus", "fog", "foil", "fold", "follow", "food", "foot",
113
+ "force", "forest", "forget", "fork", "fortune", "forum", "forward", "fossil",
114
+ "foster", "found", "fox", "fragile", "frame", "frequent", "fresh", "friend",
115
+ "fringe", "frog", "front", "frost", "frown", "frozen", "fruit", "fuel",
116
+ "fun", "funny", "furnace", "fury", "future", "gadget", "gain", "galaxy",
117
+ "gallery", "game", "gap", "garage", "garbage", "garden", "garlic", "garment",
118
+ "gas", "gasp", "gate", "gather", "gauge", "gaze", "general", "genius",
119
+ "genre", "gentle", "genuine", "gesture", "ghost", "giant", "gift", "giggle",
120
+ "ginger", "giraffe", "girl", "give", "glad", "glance", "glare", "glass",
121
+ "glide", "glimpse", "globe", "gloom", "glory", "glove", "glow", "glue",
122
+ "goat", "goddess", "gold", "good", "goose", "gorilla", "gospel", "gossip",
123
+ "govern", "gown", "grab", "grace", "grain", "grant", "grape", "grass",
124
+ "gravity", "great", "green", "grid", "grief", "grit", "grocery", "group",
125
+ "grow", "grunt", "guard", "guess", "guide", "guilt", "guitar", "gun",
126
+ "gym", "habit", "hair", "half", "hammer", "hamster", "hand", "happy",
127
+ "harbor", "hard", "harsh", "harvest", "hat", "have", "hawk", "hazard",
128
+ "head", "health", "heart", "heavy", "hedgehog", "height", "hello", "helmet",
129
+ "help", "hen", "hero", "hidden", "high", "hill", "hint", "hip",
130
+ "hire", "history", "hobby", "hockey", "hold", "hole", "holiday", "hollow",
131
+ "home", "honey", "hood", "hope", "horn", "horror", "horse", "hospital",
132
+ "host", "hotel", "hour", "hover", "hub", "huge", "human", "humble",
133
+ "humor", "hundred", "hungry", "hunt", "hurdle", "hurry", "hurt", "husband",
134
+ "hybrid", "ice", "icon", "idea", "identify", "idle", "ignore", "ill",
135
+ "illegal", "illness", "image", "imitate", "immense", "immune", "impact", "impose",
136
+ "improve", "impulse", "inch", "include", "income", "increase", "index", "indicate",
137
+ "indoor", "industry", "infant", "inflict", "inform", "inhale", "inherit", "initial",
138
+ "inject", "injury", "inmate", "inner", "innocent", "input", "inquiry", "insane",
139
+ "insect", "inside", "inspire", "install", "intact", "interest", "into", "invest",
140
+ "invite", "involve", "iron", "island", "isolate", "issue", "item", "ivory",
141
+ "jacket", "jaguar", "jar", "jazz", "jealous", "jeans", "jelly", "jewel",
142
+ "job", "join", "joke", "journey", "joy", "judge", "juice", "jump",
143
+ "jungle", "junior", "junk", "just", "kangaroo", "keen", "keep", "ketchup",
144
+ "key", "kick", "kid", "kidney", "kind", "kingdom", "kiss", "kit",
145
+ "kitchen", "kite", "kitten", "kiwi", "knee", "knife", "knock", "know",
146
+ "lab", "label", "labor", "ladder", "lady", "lake", "lamp", "language",
147
+ "laptop", "large", "later", "latin", "laugh", "laundry", "lava", "law",
148
+ "lawn", "lawsuit", "layer", "lazy", "leader", "leaf", "learn", "leave",
149
+ "lecture", "left", "leg", "legal", "legend", "leisure", "lemon", "lend",
150
+ "length", "lens", "leopard", "lesson", "letter", "level", "liar", "liberty",
151
+ "library", "license", "life", "lift", "light", "like", "limb", "limit",
152
+ "link", "lion", "liquid", "list", "little", "live", "lizard", "load",
153
+ "loan", "lobster", "local", "lock", "logic", "lonely", "long", "loop",
154
+ "lottery", "loud", "lounge", "love", "loyal", "lucky", "luggage", "lumber",
155
+ "lunar", "lunch", "luxury", "lyrics", "machine", "mad", "magic", "magnet",
156
+ "maid", "mail", "main", "major", "make", "mammal", "man", "manage",
157
+ "mandate", "mango", "mansion", "manual", "maple", "marble", "march", "margin",
158
+ "marine", "market", "marriage", "mask", "mass", "master", "match", "material",
159
+ "math", "matrix", "matter", "maximum", "maze", "meadow", "mean", "measure",
160
+ "meat", "mechanic", "medal", "media", "melody", "melt", "member", "memory",
161
+ "mention", "menu", "mercy", "merge", "merit", "merry", "mesh", "message",
162
+ "metal", "method", "middle", "midnight", "milk", "million", "mimic", "mind",
163
+ "minimum", "minor", "minute", "miracle", "mirror", "misery", "miss", "mistake",
164
+ "mix", "mixed", "mixture", "mobile", "model", "modify", "mom", "moment",
165
+ "monitor", "monkey", "monster", "month", "moon", "moral", "more", "morning",
166
+ "mosquito", "mother", "motion", "motor", "mountain", "mouse", "move", "movie",
167
+ "much", "muffin", "mule", "multiply", "muscle", "museum", "mushroom", "music",
168
+ "must", "mutual", "myself", "mystery", "myth", "naive", "name", "napkin",
169
+ "narrow", "nasty", "nation", "nature", "near", "neck", "need", "negative",
170
+ "neglect", "neither", "nephew", "nerve", "nest", "net", "network", "neutral",
171
+ "never", "news", "next", "nice", "night", "noble", "noise", "nominee",
172
+ "noodle", "normal", "north", "nose", "notable", "note", "nothing", "notice",
173
+ "novel", "now", "nuclear", "number", "nurse", "nut", "oak", "obey",
174
+ "object", "oblige", "obscure", "observe", "obtain", "obvious", "occur", "ocean",
175
+ "october", "odor", "off", "offer", "office", "often", "oil", "okay",
176
+ "old", "olive", "olympic", "omit", "once", "one", "onion", "online",
177
+ "only", "open", "opera", "opinion", "oppose", "option", "orange", "orbit",
178
+ "orchard", "order", "ordinary", "organ", "orient", "original", "orphan", "ostrich",
179
+ "other", "outdoor", "outer", "output", "outside", "oval", "oven", "over",
180
+ "own", "owner", "oxygen", "oyster", "ozone", "pact", "paddle", "page",
181
+ "pair", "palace", "palm", "panda", "panel", "panic", "panther", "paper",
182
+ "parade", "parent", "park", "parrot", "party", "pass", "patch", "path",
183
+ "patient", "patrol", "pattern", "pause", "pave", "payment", "peace", "peanut",
184
+ "pear", "peasant", "pelican", "pen", "penalty", "pencil", "people", "pepper",
185
+ "perfect", "permit", "person", "pet", "phone", "photo", "phrase", "physical",
186
+ "piano", "picnic", "picture", "piece", "pig", "pigeon", "pill", "pilot",
187
+ "pink", "pioneer", "pipe", "pistol", "pitch", "pizza", "place", "planet",
188
+ "plastic", "plate", "play", "please", "pledge", "pluck", "plug", "plunge",
189
+ "poem", "poet", "point", "polar", "pole", "police", "pond", "pony",
190
+ "pool", "popular", "portion", "position", "possible", "post", "potato", "pottery",
191
+ "poverty", "powder", "power", "practice", "praise", "predict", "prefer", "prepare",
192
+ "present", "pretty", "prevent", "price", "pride", "primary", "print", "priority",
193
+ "prison", "private", "prize", "problem", "process", "produce", "profit", "program",
194
+ "project", "promote", "proof", "property", "prosper", "protect", "proud", "provide",
195
+ "public", "pudding", "pull", "pulp", "pulse", "pumpkin", "punch", "pupil",
196
+ "puppy", "purchase", "purity", "purpose", "purse", "push", "put", "puzzle",
197
+ "pyramid", "quality", "quantum", "quarter", "question", "quick", "quit", "quiz",
198
+ "quote", "rabbit", "raccoon", "race", "rack", "radar", "radio", "rail",
199
+ "rain", "raise", "rally", "ramp", "ranch", "random", "range", "rapid",
200
+ "rare", "rate", "rather", "raven", "raw", "razor", "ready", "real",
201
+ "reason", "rebel", "rebuild", "recall", "receive", "recipe", "record", "recycle",
202
+ "reduce", "reflect", "reform", "refuse", "region", "regret", "regular", "reject",
203
+ "relax", "release", "relief", "rely", "remain", "remember", "remind", "remove",
204
+ "render", "renew", "rent", "reopen", "repair", "repeat", "replace", "report",
205
+ "require", "rescue", "resemble", "resist", "resource", "response", "result", "retire",
206
+ "retreat", "return", "reunion", "reveal", "review", "reward", "rhythm", "rib",
207
+ "ribbon", "rice", "rich", "ride", "ridge", "rifle", "right", "rigid",
208
+ "ring", "riot", "ripple", "risk", "ritual", "rival", "river", "road",
209
+ "roast", "robot", "robust", "rocket", "romance", "roof", "rookie", "room",
210
+ "rose", "rotate", "rough", "round", "route", "royal", "rubber", "rude",
211
+ "rug", "rule", "run", "runway", "rural", "sad", "saddle", "sadness",
212
+ "safe", "sail", "salad", "salmon", "salon", "salt", "salute", "same",
213
+ "sample", "sand", "satisfy", "satoshi", "sauce", "sausage", "save", "say",
214
+ "scale", "scan", "scare", "scatter", "scene", "scheme", "school", "science",
215
+ "scissors", "scorpion", "scout", "scrap", "screen", "script", "scrub", "sea",
216
+ "search", "season", "seat", "second", "secret", "section", "security", "seed",
217
+ "seek", "segment", "select", "sell", "seminar", "senior", "sense", "sentence",
218
+ "series", "service", "session", "settle", "setup", "seven", "shadow", "shaft",
219
+ "shallow", "share", "shed", "shell", "sheriff", "shield", "shift", "shine",
220
+ "ship", "shiver", "shock", "shoe", "shoot", "shop", "short", "shoulder",
221
+ "shove", "shrimp", "shrug", "shuffle", "shy", "sibling", "sick", "side",
222
+ "siege", "sight", "sign", "silent", "silk", "silly", "silver", "similar",
223
+ "simple", "since", "sing", "siren", "sister", "situate", "six", "size",
224
+ "skate", "sketch", "ski", "skill", "skin", "skirt", "skull", "slab",
225
+ "slam", "sleep", "slender", "slice", "slide", "slight", "slim", "slogan",
226
+ "slot", "slow", "slush", "small", "smart", "smile", "smoke", "smooth",
227
+ "snack", "snake", "snap", "sniff", "snow", "soap", "soccer", "social",
228
+ "sock", "soda", "soft", "solar", "soldier", "solid", "solution", "solve",
229
+ "someone", "song", "soon", "sorry", "sort", "soul", "sound", "soup",
230
+ "source", "south", "space", "spare", "spatial", "spawn", "speak", "special",
231
+ "speed", "spell", "spend", "sphere", "spice", "spider", "spike", "spin",
232
+ "spirit", "split", "spoil", "sponsor", "spoon", "sport", "spot", "spray",
233
+ "spread", "spring", "spy", "square", "squeeze", "squirrel", "stable", "stadium",
234
+ "staff", "stage", "stairs", "stamp", "stand", "start", "state", "stay",
235
+ "steak", "steel", "stem", "step", "stereo", "stick", "still", "sting",
236
+ "stock", "stomach", "stone", "stool", "story", "stove", "strategy", "street",
237
+ "strike", "strong", "struggle", "student", "stuff", "stumble", "style", "subject",
238
+ "submit", "subway", "success", "such", "sudden", "suffer", "sugar", "suggest",
239
+ "suit", "summer", "sun", "sunny", "sunset", "super", "supply", "supreme",
240
+ "sure", "surface", "surge", "surprise", "surround", "survey", "suspect", "sustain",
241
+ "swallow", "swamp", "swap", "swarm", "swear", "sweet", "swift", "swim",
242
+ "swing", "switch", "sword", "symbol", "symptom", "syrup", "system", "table",
243
+ "tackle", "tag", "tail", "talent", "talk", "tank", "tape", "target",
244
+ "task", "taste", "tattoo", "taxi", "teach", "team", "tell", "ten",
245
+ "tenant", "tennis", "tent", "term", "test", "text", "thank", "that",
246
+ "theme", "then", "theory", "there", "they", "thing", "this", "thought",
247
+ "three", "thrive", "throw", "thumb", "thunder", "ticket", "tide", "tiger",
248
+ "tilt", "timber", "time", "tiny", "tip", "tired", "tissue", "title",
249
+ "toast", "tobacco", "today", "toddler", "toe", "together", "toilet", "token",
250
+ "tomato", "tomorrow", "tone", "tongue", "tonight", "tool", "tooth", "top",
251
+ "topic", "topple", "torch", "tornado", "tortoise", "toss", "total", "tourist",
252
+ "toward", "tower", "town", "toy", "track", "trade", "traffic", "tragic",
253
+ "train", "transfer", "trap", "trash", "travel", "tray", "treat", "tree",
254
+ "trend", "trial", "tribe", "trick", "trigger", "trim", "trip", "trophy",
255
+ "trouble", "truck", "true", "truly", "trumpet", "trust", "truth", "try",
256
+ "tube", "tuition", "tumble", "tuna", "tunnel", "turkey", "turn", "turtle",
257
+ "twelve", "twenty", "twice", "twin", "twist", "two", "type", "typical",
258
+ "ugly", "umbrella", "unable", "unaware", "uncle", "uncover", "under", "undo",
259
+ "unfair", "unfold", "unhappy", "uniform", "unique", "unit", "universe", "unknown",
260
+ "unlock", "until", "unusual", "unveil", "update", "upgrade", "uphold", "upon",
261
+ "upper", "upset", "urban", "urge", "usage", "use", "used", "useful",
262
+ "useless", "usual", "utility", "vacant", "vacuum", "vague", "valid", "valley",
263
+ "valve", "van", "vanish", "vapor", "various", "vast", "vault", "vehicle",
264
+ "velvet", "vendor", "venture", "venue", "verb", "verify", "version", "very",
265
+ "vessel", "veteran", "viable", "vibrant", "vicious", "victory", "video", "view",
266
+ "village", "vintage", "violin", "virtual", "virus", "visa", "visit", "visual",
267
+ "vital", "vivid", "vocal", "voice", "void", "volcano", "volume", "vote",
268
+ "voyage", "wage", "wagon", "wait", "walk", "wall", "walnut", "want",
269
+ "warfare", "warm", "warrior", "wash", "wasp", "waste", "water", "wave",
270
+ "way", "wealth", "weapon", "wear", "weasel", "weather", "web", "wedding",
271
+ "weekend", "weird", "welcome", "west", "wet", "whale", "what", "wheat",
272
+ "wheel", "when", "where", "whip", "whisper", "wide", "width", "wife",
273
+ "wild", "will", "win", "window", "wine", "wing", "wink", "winner",
274
+ "winter", "wire", "wisdom", "wise", "wish", "witness", "wolf", "woman",
275
+ "wonder", "wood", "wool", "word", "work", "world", "worry", "worth",
276
+ "wrap", "wreck", "wrestle", "wrist", "write", "wrong", "yard", "year",
277
+ "yellow", "you", "young", "youth", "zebra", "zero", "zone", "zoo"
278
+ ];
279
+
280
+ /**
281
+ * Clean and normalize a seed phrase matching Minima's BIP39.cleanSeedPhrase() exactly
282
+ *
283
+ * From BIP39.java:
284
+ * - Split by whitespace
285
+ * - For each token: lowercase; length >= 3 required
286
+ * - If token length < 4: must match full word in wordlist
287
+ * - Else: accept FIRST word in wordlist that startsWith(token)
288
+ * - Join with single spaces, trim, then convert to UPPERCASE
289
+ *
290
+ * @param seedPhrase - Raw user input (may be abbreviated, mixed case)
291
+ * @returns Canonical uppercase phrase with full words from BIP39 list
292
+ * @throws Error if any word cannot be matched
293
+ */
294
+ export function cleanSeedPhrase(seedPhrase: string): string {
295
+ const tokens = seedPhrase.trim().split(/\s+/);
296
+ const matchedWords: string[] = [];
297
+
298
+ for (const rawToken of tokens) {
299
+ const token = rawToken.toLowerCase();
300
+
301
+ if (token.length < 3) {
302
+ throw new Error(`Word too short: "${rawToken}" (minimum 3 characters)`);
303
+ }
304
+
305
+ let found = false;
306
+
307
+ if (token.length < 4) {
308
+ for (const word of WORD_LIST) {
309
+ if (token === word) {
310
+ matchedWords.push(word);
311
+ found = true;
312
+ break;
313
+ }
314
+ }
315
+ } else {
316
+ for (const word of WORD_LIST) {
317
+ if (word.startsWith(token)) {
318
+ matchedWords.push(word);
319
+ found = true;
320
+ break;
321
+ }
322
+ }
323
+ }
324
+
325
+ if (!found) {
326
+ throw new Error(`Unknown BIP39 word: "${rawToken}"`);
327
+ }
328
+ }
329
+
330
+ return matchedWords.join(' ').trim().toUpperCase();
331
+ }
332
+
333
+ /**
334
+ * Validate that a phrase contains valid BIP39 words
335
+ * Does NOT check checksum (Minima doesn't use checksums)
336
+ *
337
+ * @param phrase - Space-separated words (any case)
338
+ * @returns true if all words are valid BIP39 words
339
+ */
340
+ export function validatePhrase(phrase: string): boolean {
341
+ try {
342
+ cleanSeedPhrase(phrase);
343
+ return true;
344
+ } catch {
345
+ return false;
346
+ }
347
+ }
348
+
349
+ /**
350
+ * Convert a seed phrase to a 32-byte seed matching Minima's BIP39.convertStringToSeed()
351
+ *
352
+ * IMPORTANT: This is NOT standard BIP39!
353
+ * Minima simply hashes the phrase bytes with SHA3-256.
354
+ * No PBKDF2, no passphrase salt, no "mnemonic" prefix.
355
+ *
356
+ * From BIP39.java convertStringToSeed():
357
+ * MiniString phrase = new MiniString(zPhrase);
358
+ * return new MiniData(Crypto.getInstance().hashData(phrase.getData()));
359
+ *
360
+ * @param phrase - Canonical phrase (should be cleaned first with cleanSeedPhrase)
361
+ * @returns 32-byte SHA3-256 seed
362
+ */
363
+ export function convertStringToSeed(phrase: string): Uint8Array {
364
+ const encoder = new TextEncoder();
365
+ const phraseBytes = encoder.encode(phrase);
366
+ return sha3_256(phraseBytes);
367
+ }
368
+
369
+ /**
370
+ * Convert word array to seed matching Minima's BIP39.convertWordListToSeed()
371
+ *
372
+ * From BIP39.java:
373
+ * String allwords = convertWordListToString(zWords);
374
+ * MiniString ministr = new MiniString(allwords);
375
+ * MiniData hash = new MiniData(Crypto.getInstance().hashData(ministr.getData()));
376
+ *
377
+ * @param words - Array of BIP39 words
378
+ * @returns 32-byte SHA3-256 seed
379
+ */
380
+ export function convertWordListToSeed(words: string[]): Uint8Array {
381
+ const phrase = words.join(' ').trim();
382
+ return convertStringToSeed(phrase);
383
+ }
384
+
385
+ /**
386
+ * Full pipeline: raw user input → 32-byte seed
387
+ *
388
+ * 1. cleanSeedPhrase() - normalize with prefix matching, output uppercase
389
+ * 2. convertStringToSeed() - SHA3-256 hash of phrase bytes
390
+ *
391
+ * @param rawPhrase - User's input (may be abbreviated, mixed case)
392
+ * @returns 32-byte seed for TreeKey
393
+ * @throws Error if phrase contains invalid words
394
+ */
395
+ export function phraseToSeed(rawPhrase: string): Uint8Array {
396
+ const canonical = cleanSeedPhrase(rawPhrase);
397
+ return convertStringToSeed(canonical);
398
+ }
399
+
400
+ /**
401
+ * Generate a new random 24-word seed phrase
402
+ * Uses crypto.getRandomValues for secure randomness
403
+ *
404
+ * @returns Array of 24 random BIP39 words (lowercase)
405
+ */
406
+ export function generateWordList(): string[] {
407
+ const words: string[] = [];
408
+ const randomValues = new Uint32Array(24);
409
+
410
+ if (typeof crypto !== 'undefined' && crypto.getRandomValues) {
411
+ crypto.getRandomValues(randomValues);
412
+ } else {
413
+ for (let i = 0; i < 24; i++) {
414
+ randomValues[i] = Math.floor(Math.random() * 0x100000000);
415
+ }
416
+ }
417
+
418
+ for (let i = 0; i < 24; i++) {
419
+ const index = randomValues[i] % WORD_LIST.length;
420
+ words.push(WORD_LIST[index]);
421
+ }
422
+
423
+ return words;
424
+ }
425
+
426
+ /**
427
+ * Generate a new random seed phrase as a string
428
+ * @returns 24-word phrase in UPPERCASE (canonical form)
429
+ */
430
+ export function generateSeedPhrase(): string {
431
+ return generateWordList().join(' ').toUpperCase();
432
+ }
@@ -0,0 +1,2 @@
1
+ export declare function scriptToAddress(script: string): string;
2
+ export declare function addressToRoot(mx: string): Uint8Array;
package/src/derive.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.scriptToAddress = scriptToAddress;
4
+ exports.addressToRoot = addressToRoot;
5
+ const mmr_1 = require("./mmr");
6
+ const minima32_1 = require("./minima32");
7
+ function scriptToAddress(script) {
8
+ const root32 = (0, mmr_1.mmrRootFromSingleLeaf)(script); // raw 32 bytes
9
+ return (0, minima32_1.encodeMx)(root32); // builds sentinel+len+checksum
10
+ }
11
+ function addressToRoot(mx) {
12
+ return (0, minima32_1.decodeMx)(mx); // returns the same raw 32 bytes, validates checksum/frame
13
+ }
package/src/derive.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { mmrRootFromSingleLeaf } from "./mmr.js";
2
+ import { makeMxAddress, parseMxAddress } from "./minima32.js";
3
+
4
+ export function scriptToAddress(script: string): string {
5
+ const root32 = mmrRootFromSingleLeaf(script);
6
+ return makeMxAddress(root32);
7
+ }
8
+
9
+ export function addressToRoot(mx: string): Uint8Array {
10
+ return parseMxAddress(mx);
11
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @module @totemsdk/core
3
+ * Core cryptographic primitives, adapters, and utilities for Minima blockchain
4
+ */
5
+ export * from './adapters';
6
+ export { LeaseStore, WatermarkStore, LeaseMonitor, prepareLease, finalizeLease, flatIndexFromLanes, type StoredLease, type LeaseStatus, type LeaseStoreConfig, type LeaseWotsIndices, type WatermarkState, type SyncResult, type WatermarkStoreConfig, type LeaseExpiryEvent, type LeaseExpiryCallback, type LeaseMonitorConfig, type PrepareArgs, type PrepareResp, } from './lease';
7
+ export { TransactionService, TransactionLifecycle, TransactionLifecycleError, WatermarkExhaustedError, TransactionReceiptStore, type TransactionServiceConfig, type WotsSigningDependencies, type TransactionLifecycleConfig, type WatermarkSyncFunction, type PrepareResult, type TransactionReceiptStoreConfig, type PrepareRequest, type PrepareResponse, type SignRequest, type SignResult, type WitnessBundle, type FinalizeRequest, type FinalizeResponse, type TransactionMetadata, type TransactionReceipt, type TransactionError, } from './tx';
8
+ export type { WotsIndices } from './tx';
9
+ export * from './utils';
10
+ export { F, hex, fromHex, u16be, u32be, assert32, h, prfChainSeed, toWinternitzDigits, baseWWithChecksum, derivePKdigest, wotsKeypairFromSeed, wotsSign, wotsSignLegacy, wotsPkFromSig, wotsVerify, wotsPublicKeyFromSeed, type WotsKeypair, type WotsSignature, } from './wots';
11
+ export * from './params';
12
+ export { serializeMiniNumber, serializeMiniData, hashAllObjects, deriveChainSeedJava, deriveChildTreeSeedJava, hashObject, serializeMiniNumberZERO, serializeMiniNumberONE, writeHashToStream, javaHashAllObjects, indexToMiniDataBytes, derivePerAddressSeed, createMMREntryNumber, serializeMMREntryNumber, serializeMMRData, serializeMMREntry, type MMREntryNumber as JavaMMREntryNumber, type MMRData as JavaMMRData, type MMREntry as JavaMMREntry, } from './javaStreamables';
13
+ export { TreeKey, type KeyGenProgress, type ProgressCallback, TreeKeyNode, verifyTreeSignature, serializeTreeSignature, deserializeTreeSignature, getRootPublicKey, DEFAULT_KEYS_PER_LEVEL, DEFAULT_LEVELS, type SignatureProof, type TreeSignature, createPerAddressTreeKey, createPerAddressTreeKeyAsync, deriveAddressPublicKey, getPerAddressPublicKey, } from './treekey';
14
+ export { scriptFromWotsPk, wotsAddressFromKeypair } from './script';
15
+ export * from './minima32';
16
+ export * from './mmr';
17
+ export { scriptToAddress, addressToRoot } from './derive';
18
+ export { WORD_LIST, cleanSeedPhrase, validatePhrase, convertStringToSeed, convertWordListToSeed, phraseToSeed, generateWordList, generateSeedPhrase, } from './bip39';
19
+ export declare const MINIMA_CONSTANTS: {
20
+ readonly WOTS_W: 8;
21
+ readonly WOTS_N: 32;
22
+ readonly MAX_SIGNATURES: 262144;
23
+ readonly SIGNATURE_LEVELS: 3;
24
+ readonly ADDRESS_PREFIX: "Mx";
25
+ readonly NETWORK_ID: 1;
26
+ };