├── .github
└── workflows
│ └── workflow.yml
├── .gitignore
├── LICENSE
├── README.md
├── jest.config.ts
├── package-lock.json
├── package.json
├── src
├── bip39-wordlists
│ ├── english.ts
│ └── index.ts
├── crypto
│ ├── crypto-node.ts
│ └── crypto-web.ts
├── functions
│ ├── common.test.ts
│ ├── common.ts
│ ├── generate-mnemonic.test.ts
│ ├── generate-mnemonic.ts
│ ├── is-password-needed.test.ts
│ ├── is-password-needed.ts
│ ├── mnemonic-to-key-pair.test.ts
│ ├── mnemonic-to-key-pair.ts
│ ├── mnemonic-to-seed.test.ts
│ ├── mnemonic-to-seed.ts
│ ├── validate-mnemonic.test.ts
│ └── validate-mnemonic.ts
└── index.ts
├── tsconfig.json
├── tsconfig.lib.json
├── tsconfig.test.json
├── types
└── webcrypto
│ └── index.d.ts
└── webpack.config.ts
/.github/workflows/workflow.yml:
--------------------------------------------------------------------------------
1 |
2 | name: CI pipeline
3 | on:
4 | push: ~
5 | workflow_dispatch: ~
6 |
7 | jobs:
8 | tests:
9 | runs-on: ${{ matrix.os }}
10 | strategy:
11 | matrix:
12 | os:
13 | - ubuntu-latest
14 | # - macos-latest
15 | # - windows-latest
16 |
17 | node_version:
18 | - 15.14.0
19 | - 16.13.0
20 | - 17.1.0
21 |
22 | env:
23 | OS: ${{ matrix.os }}
24 | NODE_VERSION: ${{ matrix.node_version }}
25 |
26 | steps:
27 | - name: Code check-out
28 | uses: actions/checkout@v2
29 |
30 | - name: Node.js set-up
31 | uses: actions/setup-node@v2
32 | with:
33 | node-version: ${{ matrix.node_version }}
34 |
35 | - name: Install dependencies
36 | run: npm ci
37 |
38 | - name: Running tests with coverage
39 | run: npm run test:coverage
40 |
41 | - name: Test report (dorny)
42 | uses: dorny/test-reporter@v1
43 | if: always()
44 | with:
45 | name: Test report [${{ matrix.os }}, ${{ matrix.node_version }}] (dorny)
46 | path: test-reports/junit.xml
47 | reporter: jest-junit
48 |
49 | - name: Test report (EnricoMi)
50 | uses: EnricoMi/publish-unit-test-result-action@v1
51 | if: always()
52 | with:
53 | files: test-reports/junit.xml
54 | check_name: Test report [${{ matrix.os }}, ${{ matrix.node_version }}] (EnricoMi)
55 |
56 | - name: Upload coverage to Codecov
57 | uses: codecov/codecov-action@v2
58 | if: always()
59 | with:
60 | token: ${{ secrets.CODECOV_TOKEN }}
61 | fail_ci_if_error: true
62 | verbose: true
63 | env_vars: OS,NODE_VERSION
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /.idea/
2 | /coverage/
3 | /dist/
4 | /node_modules/
5 | /test-reports/
6 | *.iml
7 | .DS_Store
8 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # tonweb-mnemonic
3 |
4 | [](https://www.npmjs.org/package/tonweb-mnemonic)
5 |
6 | Mnemonic code for generating deterministic keys for TON blockchain.
7 |
8 |
9 | ## Features
10 |
11 | - library interface is similar to the library `bitcoinjs/bip39`
12 | (mnemonic for Bitcoin),
13 | - there is only one dependency: `tweetnacl`,
14 | - supports both Browser (UMD) and Node.js (>=15, CommonJS)
15 | - written in TypeScript and provides typing declarations
16 |
17 |
18 | ## Install
19 |
20 | `npm install --save tonweb-mnemonic`
21 |
22 |
23 | ## Usage in browser
24 |
25 | ```html
26 | ``
27 | ``
28 |
29 |
33 | ```
34 |
35 |
36 | ## Usage in Node.js
37 |
38 | ```js
39 | import tonMnemonic from "tonweb-mnemonic";
40 |
41 | async function example() {
42 | tonMnemonic.wordlists.EN;
43 | // -> array of all words
44 |
45 | const mnemonic = await tonMnemonic.generateMnemonic();
46 | // -> ["vintage", "nice", "initial", ... ] 24 words by default
47 |
48 | await tonMnemonic.validateMnemonic(mnemonic);
49 | // -> true
50 |
51 | await tonMnemonic.isPasswordNeeded(mnemonic);
52 | // -> false
53 |
54 | await tonMnemonic.mnemonicToSeed(mnemonic);
55 | // -> Uint8Array(32) [183, 90, 187, 181, .. ]
56 |
57 | const keyPair = await tonMnemonic.mnemonicToKeyPair(mnemonic);
58 | // -> {publicKey: Uint8Array(32), secretKey: Uint8Array(64)}
59 |
60 | toHexString(keyPair.publicKey);
61 | // -> "8c8dfc9f9f58badd76151775ff0699bb2498939f669eaef2de16f95a52888c65"
62 |
63 | toHexString(keyPair.secretKey);
64 | // -> "b75abbb599feed077c8e11cc8cadecfce4945a7869a56d3d38b59cce057a3e0f8c8dfc9f9f58badd76151775ff0699bb2498939f669eaef2de16f95a52888c65"
65 | }
66 |
67 | function toHexString(byteArray) {
68 | return Array.prototype.map.call(byteArray, function(byte) {
69 | return ('0' + (byte & 0xFF).toString(16)).slice(-2);
70 | }).join('');
71 | }
72 | ```
73 |
74 |
75 | ## Contributing
76 |
77 | We will gladly accept any useful contributions.
78 |
79 |
80 | ### TO DO:
81 |
82 | - write tests for all functions (improve tests coverage)
83 | - implement tests execution on all OSes in Node
84 | - implement tests execution in Browser (i.e. headless Chrome)
85 |
86 |
87 | ### Development guide
88 |
89 | `npm install` — to install dependencies
90 |
91 | `npm run build` — to make a *development* build
92 |
93 | `npm run build:ci` — to make a *production* build
94 |
95 | `npm run test:manual` — to run manual tests in the browser
96 |
97 |
98 | ## Contributors
99 |
100 | - [rulon](https://github.com/rulon)
101 | - [tolya-yanot](https://github.com/tolya-yanot)
102 | - [Slava Fomin II](https://github.com/slavafomin)
103 |
--------------------------------------------------------------------------------
/jest.config.ts:
--------------------------------------------------------------------------------
1 |
2 | import type { Config } from '@jest/types';
3 |
4 |
5 | export default {
6 | preset: 'ts-jest',
7 | testEnvironment: 'node',
8 | verbose: true,
9 | reporters: [
10 | 'default',
11 | ['jest-junit', {
12 | outputDirectory: '/test-reports/',
13 | }],
14 | ],
15 | roots: [
16 | '/src/',
17 | ],
18 | testMatch: [
19 | '**/*.test.ts',
20 | ],
21 | collectCoverageFrom: [
22 | '**/*.ts',
23 | ],
24 | errorOnDeprecated: true,
25 | globals: {
26 | 'ts-jest': {
27 | tsconfig: 'tsconfig.lib.json',
28 | },
29 | },
30 | };
31 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tonweb-mnemonic",
3 | "version": "1.0.1",
4 | "description": "Mnemonic code for generating deterministic keys for TON (The Open Network)",
5 | "main": "dist/node",
6 | "browser": "dist/web",
7 | "types": "dist/types",
8 | "scripts": {
9 | "build": "rm -rf ./dist && webpack build && npm run build:types",
10 | "build:ci": "NODE_ENV=production npm run build",
11 | "build:node": "webpack build --config-name node",
12 | "build:types": "tsc -p ./tsconfig.lib.json",
13 | "build:web": "webpack build --config-name web",
14 | "prepublishOnly": "npm run build:ci",
15 | "test": "jest",
16 | "test:coverage": "jest --coverage",
17 | "test:manual": "browser-sync start --server --index ./test/index.html --files ./dist"
18 | },
19 | "keywords": [
20 | "BIP39",
21 | "Blockchain",
22 | "Mnemonic",
23 | "TON",
24 | "The Open Network"
25 | ],
26 | "contributors": [
27 | {
28 | "name": "rulon",
29 | "url": "https://github.com/EmelyanenkoK"
30 | },
31 | {
32 | "name": "tolyayanot",
33 | "url": "https://github.com/tolya-yanot"
34 | },
35 | {
36 | "name": "Slava Fomin II",
37 | "email": "slava@fomin.io",
38 | "url": "https://github.com/slavafomin"
39 | }
40 | ],
41 | "license": "GPL-3.0",
42 | "bugs": {
43 | "url": "https://github.com/toncenter/tonweb-mnemonic/issues"
44 | },
45 | "homepage": "https://github.com/toncenter/tonweb-mnemonic#readme",
46 | "engines": {
47 | "node": ">=15"
48 | },
49 | "files": [
50 | "dist/"
51 | ],
52 | "dependencies": {
53 | "tweetnacl": "^1.0.3"
54 | },
55 | "devDependencies": {
56 | "@babel/core": "^7.16.0",
57 | "@babel/plugin-transform-runtime": "^7.16.4",
58 | "@babel/preset-typescript": "^7.16.0",
59 | "@types/jest": "^27.0.3",
60 | "@types/node": "^16.11.8",
61 | "@types/webpack": "^5.28.0",
62 | "babel-loader": "^8.2.3",
63 | "browser-sync": "^2.27.7",
64 | "fork-ts-checker-webpack-plugin": "^6.4.0",
65 | "jest": "^27.3.1",
66 | "jest-junit": "^13.0.0",
67 | "npm-run-all": "^4.1.5",
68 | "ts-jest": "^27.0.7",
69 | "ts-node": "^10.4.0",
70 | "typescript": "^4.5.2",
71 | "webpack": "^5.64.1",
72 | "webpack-cli": "^4.9.1",
73 | "webpack-merge": "^5.8.0",
74 | "webpack-node-externals": "^3.0.0"
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/bip39-wordlists/english.ts:
--------------------------------------------------------------------------------
1 |
2 | export default [
3 | 'abandon',
4 | 'ability',
5 | 'able',
6 | 'about',
7 | 'above',
8 | 'absent',
9 | 'absorb',
10 | 'abstract',
11 | 'absurd',
12 | 'abuse',
13 | 'access',
14 | 'accident',
15 | 'account',
16 | 'accuse',
17 | 'achieve',
18 | 'acid',
19 | 'acoustic',
20 | 'acquire',
21 | 'across',
22 | 'act',
23 | 'action',
24 | 'actor',
25 | 'actress',
26 | 'actual',
27 | 'adapt',
28 | 'add',
29 | 'addict',
30 | 'address',
31 | 'adjust',
32 | 'admit',
33 | 'adult',
34 | 'advance',
35 | 'advice',
36 | 'aerobic',
37 | 'affair',
38 | 'afford',
39 | 'afraid',
40 | 'again',
41 | 'age',
42 | 'agent',
43 | 'agree',
44 | 'ahead',
45 | 'aim',
46 | 'air',
47 | 'airport',
48 | 'aisle',
49 | 'alarm',
50 | 'album',
51 | 'alcohol',
52 | 'alert',
53 | 'alien',
54 | 'all',
55 | 'alley',
56 | 'allow',
57 | 'almost',
58 | 'alone',
59 | 'alpha',
60 | 'already',
61 | 'also',
62 | 'alter',
63 | 'always',
64 | 'amateur',
65 | 'amazing',
66 | 'among',
67 | 'amount',
68 | 'amused',
69 | 'analyst',
70 | 'anchor',
71 | 'ancient',
72 | 'anger',
73 | 'angle',
74 | 'angry',
75 | 'animal',
76 | 'ankle',
77 | 'announce',
78 | 'annual',
79 | 'another',
80 | 'answer',
81 | 'antenna',
82 | 'antique',
83 | 'anxiety',
84 | 'any',
85 | 'apart',
86 | 'apology',
87 | 'appear',
88 | 'apple',
89 | 'approve',
90 | 'april',
91 | 'arch',
92 | 'arctic',
93 | 'area',
94 | 'arena',
95 | 'argue',
96 | 'arm',
97 | 'armed',
98 | 'armor',
99 | 'army',
100 | 'around',
101 | 'arrange',
102 | 'arrest',
103 | 'arrive',
104 | 'arrow',
105 | 'art',
106 | 'artefact',
107 | 'artist',
108 | 'artwork',
109 | 'ask',
110 | 'aspect',
111 | 'assault',
112 | 'asset',
113 | 'assist',
114 | 'assume',
115 | 'asthma',
116 | 'athlete',
117 | 'atom',
118 | 'attack',
119 | 'attend',
120 | 'attitude',
121 | 'attract',
122 | 'auction',
123 | 'audit',
124 | 'august',
125 | 'aunt',
126 | 'author',
127 | 'auto',
128 | 'autumn',
129 | 'average',
130 | 'avocado',
131 | 'avoid',
132 | 'awake',
133 | 'aware',
134 | 'away',
135 | 'awesome',
136 | 'awful',
137 | 'awkward',
138 | 'axis',
139 | 'baby',
140 | 'bachelor',
141 | 'bacon',
142 | 'badge',
143 | 'bag',
144 | 'balance',
145 | 'balcony',
146 | 'ball',
147 | 'bamboo',
148 | 'banana',
149 | 'banner',
150 | 'bar',
151 | 'barely',
152 | 'bargain',
153 | 'barrel',
154 | 'base',
155 | 'basic',
156 | 'basket',
157 | 'battle',
158 | 'beach',
159 | 'bean',
160 | 'beauty',
161 | 'because',
162 | 'become',
163 | 'beef',
164 | 'before',
165 | 'begin',
166 | 'behave',
167 | 'behind',
168 | 'believe',
169 | 'below',
170 | 'belt',
171 | 'bench',
172 | 'benefit',
173 | 'best',
174 | 'betray',
175 | 'better',
176 | 'between',
177 | 'beyond',
178 | 'bicycle',
179 | 'bid',
180 | 'bike',
181 | 'bind',
182 | 'biology',
183 | 'bird',
184 | 'birth',
185 | 'bitter',
186 | 'black',
187 | 'blade',
188 | 'blame',
189 | 'blanket',
190 | 'blast',
191 | 'bleak',
192 | 'bless',
193 | 'blind',
194 | 'blood',
195 | 'blossom',
196 | 'blouse',
197 | 'blue',
198 | 'blur',
199 | 'blush',
200 | 'board',
201 | 'boat',
202 | 'body',
203 | 'boil',
204 | 'bomb',
205 | 'bone',
206 | 'bonus',
207 | 'book',
208 | 'boost',
209 | 'border',
210 | 'boring',
211 | 'borrow',
212 | 'boss',
213 | 'bottom',
214 | 'bounce',
215 | 'box',
216 | 'boy',
217 | 'bracket',
218 | 'brain',
219 | 'brand',
220 | 'brass',
221 | 'brave',
222 | 'bread',
223 | 'breeze',
224 | 'brick',
225 | 'bridge',
226 | 'brief',
227 | 'bright',
228 | 'bring',
229 | 'brisk',
230 | 'broccoli',
231 | 'broken',
232 | 'bronze',
233 | 'broom',
234 | 'brother',
235 | 'brown',
236 | 'brush',
237 | 'bubble',
238 | 'buddy',
239 | 'budget',
240 | 'buffalo',
241 | 'build',
242 | 'bulb',
243 | 'bulk',
244 | 'bullet',
245 | 'bundle',
246 | 'bunker',
247 | 'burden',
248 | 'burger',
249 | 'burst',
250 | 'bus',
251 | 'business',
252 | 'busy',
253 | 'butter',
254 | 'buyer',
255 | 'buzz',
256 | 'cabbage',
257 | 'cabin',
258 | 'cable',
259 | 'cactus',
260 | 'cage',
261 | 'cake',
262 | 'call',
263 | 'calm',
264 | 'camera',
265 | 'camp',
266 | 'can',
267 | 'canal',
268 | 'cancel',
269 | 'candy',
270 | 'cannon',
271 | 'canoe',
272 | 'canvas',
273 | 'canyon',
274 | 'capable',
275 | 'capital',
276 | 'captain',
277 | 'car',
278 | 'carbon',
279 | 'card',
280 | 'cargo',
281 | 'carpet',
282 | 'carry',
283 | 'cart',
284 | 'case',
285 | 'cash',
286 | 'casino',
287 | 'castle',
288 | 'casual',
289 | 'cat',
290 | 'catalog',
291 | 'catch',
292 | 'category',
293 | 'cattle',
294 | 'caught',
295 | 'cause',
296 | 'caution',
297 | 'cave',
298 | 'ceiling',
299 | 'celery',
300 | 'cement',
301 | 'census',
302 | 'century',
303 | 'cereal',
304 | 'certain',
305 | 'chair',
306 | 'chalk',
307 | 'champion',
308 | 'change',
309 | 'chaos',
310 | 'chapter',
311 | 'charge',
312 | 'chase',
313 | 'chat',
314 | 'cheap',
315 | 'check',
316 | 'cheese',
317 | 'chef',
318 | 'cherry',
319 | 'chest',
320 | 'chicken',
321 | 'chief',
322 | 'child',
323 | 'chimney',
324 | 'choice',
325 | 'choose',
326 | 'chronic',
327 | 'chuckle',
328 | 'chunk',
329 | 'churn',
330 | 'cigar',
331 | 'cinnamon',
332 | 'circle',
333 | 'citizen',
334 | 'city',
335 | 'civil',
336 | 'claim',
337 | 'clap',
338 | 'clarify',
339 | 'claw',
340 | 'clay',
341 | 'clean',
342 | 'clerk',
343 | 'clever',
344 | 'click',
345 | 'client',
346 | 'cliff',
347 | 'climb',
348 | 'clinic',
349 | 'clip',
350 | 'clock',
351 | 'clog',
352 | 'close',
353 | 'cloth',
354 | 'cloud',
355 | 'clown',
356 | 'club',
357 | 'clump',
358 | 'cluster',
359 | 'clutch',
360 | 'coach',
361 | 'coast',
362 | 'coconut',
363 | 'code',
364 | 'coffee',
365 | 'coil',
366 | 'coin',
367 | 'collect',
368 | 'color',
369 | 'column',
370 | 'combine',
371 | 'come',
372 | 'comfort',
373 | 'comic',
374 | 'common',
375 | 'company',
376 | 'concert',
377 | 'conduct',
378 | 'confirm',
379 | 'congress',
380 | 'connect',
381 | 'consider',
382 | 'control',
383 | 'convince',
384 | 'cook',
385 | 'cool',
386 | 'copper',
387 | 'copy',
388 | 'coral',
389 | 'core',
390 | 'corn',
391 | 'correct',
392 | 'cost',
393 | 'cotton',
394 | 'couch',
395 | 'country',
396 | 'couple',
397 | 'course',
398 | 'cousin',
399 | 'cover',
400 | 'coyote',
401 | 'crack',
402 | 'cradle',
403 | 'craft',
404 | 'cram',
405 | 'crane',
406 | 'crash',
407 | 'crater',
408 | 'crawl',
409 | 'crazy',
410 | 'cream',
411 | 'credit',
412 | 'creek',
413 | 'crew',
414 | 'cricket',
415 | 'crime',
416 | 'crisp',
417 | 'critic',
418 | 'crop',
419 | 'cross',
420 | 'crouch',
421 | 'crowd',
422 | 'crucial',
423 | 'cruel',
424 | 'cruise',
425 | 'crumble',
426 | 'crunch',
427 | 'crush',
428 | 'cry',
429 | 'crystal',
430 | 'cube',
431 | 'culture',
432 | 'cup',
433 | 'cupboard',
434 | 'curious',
435 | 'current',
436 | 'curtain',
437 | 'curve',
438 | 'cushion',
439 | 'custom',
440 | 'cute',
441 | 'cycle',
442 | 'dad',
443 | 'damage',
444 | 'damp',
445 | 'dance',
446 | 'danger',
447 | 'daring',
448 | 'dash',
449 | 'daughter',
450 | 'dawn',
451 | 'day',
452 | 'deal',
453 | 'debate',
454 | 'debris',
455 | 'decade',
456 | 'december',
457 | 'decide',
458 | 'decline',
459 | 'decorate',
460 | 'decrease',
461 | 'deer',
462 | 'defense',
463 | 'define',
464 | 'defy',
465 | 'degree',
466 | 'delay',
467 | 'deliver',
468 | 'demand',
469 | 'demise',
470 | 'denial',
471 | 'dentist',
472 | 'deny',
473 | 'depart',
474 | 'depend',
475 | 'deposit',
476 | 'depth',
477 | 'deputy',
478 | 'derive',
479 | 'describe',
480 | 'desert',
481 | 'design',
482 | 'desk',
483 | 'despair',
484 | 'destroy',
485 | 'detail',
486 | 'detect',
487 | 'develop',
488 | 'device',
489 | 'devote',
490 | 'diagram',
491 | 'dial',
492 | 'diamond',
493 | 'diary',
494 | 'dice',
495 | 'diesel',
496 | 'diet',
497 | 'differ',
498 | 'digital',
499 | 'dignity',
500 | 'dilemma',
501 | 'dinner',
502 | 'dinosaur',
503 | 'direct',
504 | 'dirt',
505 | 'disagree',
506 | 'discover',
507 | 'disease',
508 | 'dish',
509 | 'dismiss',
510 | 'disorder',
511 | 'display',
512 | 'distance',
513 | 'divert',
514 | 'divide',
515 | 'divorce',
516 | 'dizzy',
517 | 'doctor',
518 | 'document',
519 | 'dog',
520 | 'doll',
521 | 'dolphin',
522 | 'domain',
523 | 'donate',
524 | 'donkey',
525 | 'donor',
526 | 'door',
527 | 'dose',
528 | 'double',
529 | 'dove',
530 | 'draft',
531 | 'dragon',
532 | 'drama',
533 | 'drastic',
534 | 'draw',
535 | 'dream',
536 | 'dress',
537 | 'drift',
538 | 'drill',
539 | 'drink',
540 | 'drip',
541 | 'drive',
542 | 'drop',
543 | 'drum',
544 | 'dry',
545 | 'duck',
546 | 'dumb',
547 | 'dune',
548 | 'during',
549 | 'dust',
550 | 'dutch',
551 | 'duty',
552 | 'dwarf',
553 | 'dynamic',
554 | 'eager',
555 | 'eagle',
556 | 'early',
557 | 'earn',
558 | 'earth',
559 | 'easily',
560 | 'east',
561 | 'easy',
562 | 'echo',
563 | 'ecology',
564 | 'economy',
565 | 'edge',
566 | 'edit',
567 | 'educate',
568 | 'effort',
569 | 'egg',
570 | 'eight',
571 | 'either',
572 | 'elbow',
573 | 'elder',
574 | 'electric',
575 | 'elegant',
576 | 'element',
577 | 'elephant',
578 | 'elevator',
579 | 'elite',
580 | 'else',
581 | 'embark',
582 | 'embody',
583 | 'embrace',
584 | 'emerge',
585 | 'emotion',
586 | 'employ',
587 | 'empower',
588 | 'empty',
589 | 'enable',
590 | 'enact',
591 | 'end',
592 | 'endless',
593 | 'endorse',
594 | 'enemy',
595 | 'energy',
596 | 'enforce',
597 | 'engage',
598 | 'engine',
599 | 'enhance',
600 | 'enjoy',
601 | 'enlist',
602 | 'enough',
603 | 'enrich',
604 | 'enroll',
605 | 'ensure',
606 | 'enter',
607 | 'entire',
608 | 'entry',
609 | 'envelope',
610 | 'episode',
611 | 'equal',
612 | 'equip',
613 | 'era',
614 | 'erase',
615 | 'erode',
616 | 'erosion',
617 | 'error',
618 | 'erupt',
619 | 'escape',
620 | 'essay',
621 | 'essence',
622 | 'estate',
623 | 'eternal',
624 | 'ethics',
625 | 'evidence',
626 | 'evil',
627 | 'evoke',
628 | 'evolve',
629 | 'exact',
630 | 'example',
631 | 'excess',
632 | 'exchange',
633 | 'excite',
634 | 'exclude',
635 | 'excuse',
636 | 'execute',
637 | 'exercise',
638 | 'exhaust',
639 | 'exhibit',
640 | 'exile',
641 | 'exist',
642 | 'exit',
643 | 'exotic',
644 | 'expand',
645 | 'expect',
646 | 'expire',
647 | 'explain',
648 | 'expose',
649 | 'express',
650 | 'extend',
651 | 'extra',
652 | 'eye',
653 | 'eyebrow',
654 | 'fabric',
655 | 'face',
656 | 'faculty',
657 | 'fade',
658 | 'faint',
659 | 'faith',
660 | 'fall',
661 | 'false',
662 | 'fame',
663 | 'family',
664 | 'famous',
665 | 'fan',
666 | 'fancy',
667 | 'fantasy',
668 | 'farm',
669 | 'fashion',
670 | 'fat',
671 | 'fatal',
672 | 'father',
673 | 'fatigue',
674 | 'fault',
675 | 'favorite',
676 | 'feature',
677 | 'february',
678 | 'federal',
679 | 'fee',
680 | 'feed',
681 | 'feel',
682 | 'female',
683 | 'fence',
684 | 'festival',
685 | 'fetch',
686 | 'fever',
687 | 'few',
688 | 'fiber',
689 | 'fiction',
690 | 'field',
691 | 'figure',
692 | 'file',
693 | 'film',
694 | 'filter',
695 | 'final',
696 | 'find',
697 | 'fine',
698 | 'finger',
699 | 'finish',
700 | 'fire',
701 | 'firm',
702 | 'first',
703 | 'fiscal',
704 | 'fish',
705 | 'fit',
706 | 'fitness',
707 | 'fix',
708 | 'flag',
709 | 'flame',
710 | 'flash',
711 | 'flat',
712 | 'flavor',
713 | 'flee',
714 | 'flight',
715 | 'flip',
716 | 'float',
717 | 'flock',
718 | 'floor',
719 | 'flower',
720 | 'fluid',
721 | 'flush',
722 | 'fly',
723 | 'foam',
724 | 'focus',
725 | 'fog',
726 | 'foil',
727 | 'fold',
728 | 'follow',
729 | 'food',
730 | 'foot',
731 | 'force',
732 | 'forest',
733 | 'forget',
734 | 'fork',
735 | 'fortune',
736 | 'forum',
737 | 'forward',
738 | 'fossil',
739 | 'foster',
740 | 'found',
741 | 'fox',
742 | 'fragile',
743 | 'frame',
744 | 'frequent',
745 | 'fresh',
746 | 'friend',
747 | 'fringe',
748 | 'frog',
749 | 'front',
750 | 'frost',
751 | 'frown',
752 | 'frozen',
753 | 'fruit',
754 | 'fuel',
755 | 'fun',
756 | 'funny',
757 | 'furnace',
758 | 'fury',
759 | 'future',
760 | 'gadget',
761 | 'gain',
762 | 'galaxy',
763 | 'gallery',
764 | 'game',
765 | 'gap',
766 | 'garage',
767 | 'garbage',
768 | 'garden',
769 | 'garlic',
770 | 'garment',
771 | 'gas',
772 | 'gasp',
773 | 'gate',
774 | 'gather',
775 | 'gauge',
776 | 'gaze',
777 | 'general',
778 | 'genius',
779 | 'genre',
780 | 'gentle',
781 | 'genuine',
782 | 'gesture',
783 | 'ghost',
784 | 'giant',
785 | 'gift',
786 | 'giggle',
787 | 'ginger',
788 | 'giraffe',
789 | 'girl',
790 | 'give',
791 | 'glad',
792 | 'glance',
793 | 'glare',
794 | 'glass',
795 | 'glide',
796 | 'glimpse',
797 | 'globe',
798 | 'gloom',
799 | 'glory',
800 | 'glove',
801 | 'glow',
802 | 'glue',
803 | 'goat',
804 | 'goddess',
805 | 'gold',
806 | 'good',
807 | 'goose',
808 | 'gorilla',
809 | 'gospel',
810 | 'gossip',
811 | 'govern',
812 | 'gown',
813 | 'grab',
814 | 'grace',
815 | 'grain',
816 | 'grant',
817 | 'grape',
818 | 'grass',
819 | 'gravity',
820 | 'great',
821 | 'green',
822 | 'grid',
823 | 'grief',
824 | 'grit',
825 | 'grocery',
826 | 'group',
827 | 'grow',
828 | 'grunt',
829 | 'guard',
830 | 'guess',
831 | 'guide',
832 | 'guilt',
833 | 'guitar',
834 | 'gun',
835 | 'gym',
836 | 'habit',
837 | 'hair',
838 | 'half',
839 | 'hammer',
840 | 'hamster',
841 | 'hand',
842 | 'happy',
843 | 'harbor',
844 | 'hard',
845 | 'harsh',
846 | 'harvest',
847 | 'hat',
848 | 'have',
849 | 'hawk',
850 | 'hazard',
851 | 'head',
852 | 'health',
853 | 'heart',
854 | 'heavy',
855 | 'hedgehog',
856 | 'height',
857 | 'hello',
858 | 'helmet',
859 | 'help',
860 | 'hen',
861 | 'hero',
862 | 'hidden',
863 | 'high',
864 | 'hill',
865 | 'hint',
866 | 'hip',
867 | 'hire',
868 | 'history',
869 | 'hobby',
870 | 'hockey',
871 | 'hold',
872 | 'hole',
873 | 'holiday',
874 | 'hollow',
875 | 'home',
876 | 'honey',
877 | 'hood',
878 | 'hope',
879 | 'horn',
880 | 'horror',
881 | 'horse',
882 | 'hospital',
883 | 'host',
884 | 'hotel',
885 | 'hour',
886 | 'hover',
887 | 'hub',
888 | 'huge',
889 | 'human',
890 | 'humble',
891 | 'humor',
892 | 'hundred',
893 | 'hungry',
894 | 'hunt',
895 | 'hurdle',
896 | 'hurry',
897 | 'hurt',
898 | 'husband',
899 | 'hybrid',
900 | 'ice',
901 | 'icon',
902 | 'idea',
903 | 'identify',
904 | 'idle',
905 | 'ignore',
906 | 'ill',
907 | 'illegal',
908 | 'illness',
909 | 'image',
910 | 'imitate',
911 | 'immense',
912 | 'immune',
913 | 'impact',
914 | 'impose',
915 | 'improve',
916 | 'impulse',
917 | 'inch',
918 | 'include',
919 | 'income',
920 | 'increase',
921 | 'index',
922 | 'indicate',
923 | 'indoor',
924 | 'industry',
925 | 'infant',
926 | 'inflict',
927 | 'inform',
928 | 'inhale',
929 | 'inherit',
930 | 'initial',
931 | 'inject',
932 | 'injury',
933 | 'inmate',
934 | 'inner',
935 | 'innocent',
936 | 'input',
937 | 'inquiry',
938 | 'insane',
939 | 'insect',
940 | 'inside',
941 | 'inspire',
942 | 'install',
943 | 'intact',
944 | 'interest',
945 | 'into',
946 | 'invest',
947 | 'invite',
948 | 'involve',
949 | 'iron',
950 | 'island',
951 | 'isolate',
952 | 'issue',
953 | 'item',
954 | 'ivory',
955 | 'jacket',
956 | 'jaguar',
957 | 'jar',
958 | 'jazz',
959 | 'jealous',
960 | 'jeans',
961 | 'jelly',
962 | 'jewel',
963 | 'job',
964 | 'join',
965 | 'joke',
966 | 'journey',
967 | 'joy',
968 | 'judge',
969 | 'juice',
970 | 'jump',
971 | 'jungle',
972 | 'junior',
973 | 'junk',
974 | 'just',
975 | 'kangaroo',
976 | 'keen',
977 | 'keep',
978 | 'ketchup',
979 | 'key',
980 | 'kick',
981 | 'kid',
982 | 'kidney',
983 | 'kind',
984 | 'kingdom',
985 | 'kiss',
986 | 'kit',
987 | 'kitchen',
988 | 'kite',
989 | 'kitten',
990 | 'kiwi',
991 | 'knee',
992 | 'knife',
993 | 'knock',
994 | 'know',
995 | 'lab',
996 | 'label',
997 | 'labor',
998 | 'ladder',
999 | 'lady',
1000 | 'lake',
1001 | 'lamp',
1002 | 'language',
1003 | 'laptop',
1004 | 'large',
1005 | 'later',
1006 | 'latin',
1007 | 'laugh',
1008 | 'laundry',
1009 | 'lava',
1010 | 'law',
1011 | 'lawn',
1012 | 'lawsuit',
1013 | 'layer',
1014 | 'lazy',
1015 | 'leader',
1016 | 'leaf',
1017 | 'learn',
1018 | 'leave',
1019 | 'lecture',
1020 | 'left',
1021 | 'leg',
1022 | 'legal',
1023 | 'legend',
1024 | 'leisure',
1025 | 'lemon',
1026 | 'lend',
1027 | 'length',
1028 | 'lens',
1029 | 'leopard',
1030 | 'lesson',
1031 | 'letter',
1032 | 'level',
1033 | 'liar',
1034 | 'liberty',
1035 | 'library',
1036 | 'license',
1037 | 'life',
1038 | 'lift',
1039 | 'light',
1040 | 'like',
1041 | 'limb',
1042 | 'limit',
1043 | 'link',
1044 | 'lion',
1045 | 'liquid',
1046 | 'list',
1047 | 'little',
1048 | 'live',
1049 | 'lizard',
1050 | 'load',
1051 | 'loan',
1052 | 'lobster',
1053 | 'local',
1054 | 'lock',
1055 | 'logic',
1056 | 'lonely',
1057 | 'long',
1058 | 'loop',
1059 | 'lottery',
1060 | 'loud',
1061 | 'lounge',
1062 | 'love',
1063 | 'loyal',
1064 | 'lucky',
1065 | 'luggage',
1066 | 'lumber',
1067 | 'lunar',
1068 | 'lunch',
1069 | 'luxury',
1070 | 'lyrics',
1071 | 'machine',
1072 | 'mad',
1073 | 'magic',
1074 | 'magnet',
1075 | 'maid',
1076 | 'mail',
1077 | 'main',
1078 | 'major',
1079 | 'make',
1080 | 'mammal',
1081 | 'man',
1082 | 'manage',
1083 | 'mandate',
1084 | 'mango',
1085 | 'mansion',
1086 | 'manual',
1087 | 'maple',
1088 | 'marble',
1089 | 'march',
1090 | 'margin',
1091 | 'marine',
1092 | 'market',
1093 | 'marriage',
1094 | 'mask',
1095 | 'mass',
1096 | 'master',
1097 | 'match',
1098 | 'material',
1099 | 'math',
1100 | 'matrix',
1101 | 'matter',
1102 | 'maximum',
1103 | 'maze',
1104 | 'meadow',
1105 | 'mean',
1106 | 'measure',
1107 | 'meat',
1108 | 'mechanic',
1109 | 'medal',
1110 | 'media',
1111 | 'melody',
1112 | 'melt',
1113 | 'member',
1114 | 'memory',
1115 | 'mention',
1116 | 'menu',
1117 | 'mercy',
1118 | 'merge',
1119 | 'merit',
1120 | 'merry',
1121 | 'mesh',
1122 | 'message',
1123 | 'metal',
1124 | 'method',
1125 | 'middle',
1126 | 'midnight',
1127 | 'milk',
1128 | 'million',
1129 | 'mimic',
1130 | 'mind',
1131 | 'minimum',
1132 | 'minor',
1133 | 'minute',
1134 | 'miracle',
1135 | 'mirror',
1136 | 'misery',
1137 | 'miss',
1138 | 'mistake',
1139 | 'mix',
1140 | 'mixed',
1141 | 'mixture',
1142 | 'mobile',
1143 | 'model',
1144 | 'modify',
1145 | 'mom',
1146 | 'moment',
1147 | 'monitor',
1148 | 'monkey',
1149 | 'monster',
1150 | 'month',
1151 | 'moon',
1152 | 'moral',
1153 | 'more',
1154 | 'morning',
1155 | 'mosquito',
1156 | 'mother',
1157 | 'motion',
1158 | 'motor',
1159 | 'mountain',
1160 | 'mouse',
1161 | 'move',
1162 | 'movie',
1163 | 'much',
1164 | 'muffin',
1165 | 'mule',
1166 | 'multiply',
1167 | 'muscle',
1168 | 'museum',
1169 | 'mushroom',
1170 | 'music',
1171 | 'must',
1172 | 'mutual',
1173 | 'myself',
1174 | 'mystery',
1175 | 'myth',
1176 | 'naive',
1177 | 'name',
1178 | 'napkin',
1179 | 'narrow',
1180 | 'nasty',
1181 | 'nation',
1182 | 'nature',
1183 | 'near',
1184 | 'neck',
1185 | 'need',
1186 | 'negative',
1187 | 'neglect',
1188 | 'neither',
1189 | 'nephew',
1190 | 'nerve',
1191 | 'nest',
1192 | 'net',
1193 | 'network',
1194 | 'neutral',
1195 | 'never',
1196 | 'news',
1197 | 'next',
1198 | 'nice',
1199 | 'night',
1200 | 'noble',
1201 | 'noise',
1202 | 'nominee',
1203 | 'noodle',
1204 | 'normal',
1205 | 'north',
1206 | 'nose',
1207 | 'notable',
1208 | 'note',
1209 | 'nothing',
1210 | 'notice',
1211 | 'novel',
1212 | 'now',
1213 | 'nuclear',
1214 | 'number',
1215 | 'nurse',
1216 | 'nut',
1217 | 'oak',
1218 | 'obey',
1219 | 'object',
1220 | 'oblige',
1221 | 'obscure',
1222 | 'observe',
1223 | 'obtain',
1224 | 'obvious',
1225 | 'occur',
1226 | 'ocean',
1227 | 'october',
1228 | 'odor',
1229 | 'off',
1230 | 'offer',
1231 | 'office',
1232 | 'often',
1233 | 'oil',
1234 | 'okay',
1235 | 'old',
1236 | 'olive',
1237 | 'olympic',
1238 | 'omit',
1239 | 'once',
1240 | 'one',
1241 | 'onion',
1242 | 'online',
1243 | 'only',
1244 | 'open',
1245 | 'opera',
1246 | 'opinion',
1247 | 'oppose',
1248 | 'option',
1249 | 'orange',
1250 | 'orbit',
1251 | 'orchard',
1252 | 'order',
1253 | 'ordinary',
1254 | 'organ',
1255 | 'orient',
1256 | 'original',
1257 | 'orphan',
1258 | 'ostrich',
1259 | 'other',
1260 | 'outdoor',
1261 | 'outer',
1262 | 'output',
1263 | 'outside',
1264 | 'oval',
1265 | 'oven',
1266 | 'over',
1267 | 'own',
1268 | 'owner',
1269 | 'oxygen',
1270 | 'oyster',
1271 | 'ozone',
1272 | 'pact',
1273 | 'paddle',
1274 | 'page',
1275 | 'pair',
1276 | 'palace',
1277 | 'palm',
1278 | 'panda',
1279 | 'panel',
1280 | 'panic',
1281 | 'panther',
1282 | 'paper',
1283 | 'parade',
1284 | 'parent',
1285 | 'park',
1286 | 'parrot',
1287 | 'party',
1288 | 'pass',
1289 | 'patch',
1290 | 'path',
1291 | 'patient',
1292 | 'patrol',
1293 | 'pattern',
1294 | 'pause',
1295 | 'pave',
1296 | 'payment',
1297 | 'peace',
1298 | 'peanut',
1299 | 'pear',
1300 | 'peasant',
1301 | 'pelican',
1302 | 'pen',
1303 | 'penalty',
1304 | 'pencil',
1305 | 'people',
1306 | 'pepper',
1307 | 'perfect',
1308 | 'permit',
1309 | 'person',
1310 | 'pet',
1311 | 'phone',
1312 | 'photo',
1313 | 'phrase',
1314 | 'physical',
1315 | 'piano',
1316 | 'picnic',
1317 | 'picture',
1318 | 'piece',
1319 | 'pig',
1320 | 'pigeon',
1321 | 'pill',
1322 | 'pilot',
1323 | 'pink',
1324 | 'pioneer',
1325 | 'pipe',
1326 | 'pistol',
1327 | 'pitch',
1328 | 'pizza',
1329 | 'place',
1330 | 'planet',
1331 | 'plastic',
1332 | 'plate',
1333 | 'play',
1334 | 'please',
1335 | 'pledge',
1336 | 'pluck',
1337 | 'plug',
1338 | 'plunge',
1339 | 'poem',
1340 | 'poet',
1341 | 'point',
1342 | 'polar',
1343 | 'pole',
1344 | 'police',
1345 | 'pond',
1346 | 'pony',
1347 | 'pool',
1348 | 'popular',
1349 | 'portion',
1350 | 'position',
1351 | 'possible',
1352 | 'post',
1353 | 'potato',
1354 | 'pottery',
1355 | 'poverty',
1356 | 'powder',
1357 | 'power',
1358 | 'practice',
1359 | 'praise',
1360 | 'predict',
1361 | 'prefer',
1362 | 'prepare',
1363 | 'present',
1364 | 'pretty',
1365 | 'prevent',
1366 | 'price',
1367 | 'pride',
1368 | 'primary',
1369 | 'print',
1370 | 'priority',
1371 | 'prison',
1372 | 'private',
1373 | 'prize',
1374 | 'problem',
1375 | 'process',
1376 | 'produce',
1377 | 'profit',
1378 | 'program',
1379 | 'project',
1380 | 'promote',
1381 | 'proof',
1382 | 'property',
1383 | 'prosper',
1384 | 'protect',
1385 | 'proud',
1386 | 'provide',
1387 | 'public',
1388 | 'pudding',
1389 | 'pull',
1390 | 'pulp',
1391 | 'pulse',
1392 | 'pumpkin',
1393 | 'punch',
1394 | 'pupil',
1395 | 'puppy',
1396 | 'purchase',
1397 | 'purity',
1398 | 'purpose',
1399 | 'purse',
1400 | 'push',
1401 | 'put',
1402 | 'puzzle',
1403 | 'pyramid',
1404 | 'quality',
1405 | 'quantum',
1406 | 'quarter',
1407 | 'question',
1408 | 'quick',
1409 | 'quit',
1410 | 'quiz',
1411 | 'quote',
1412 | 'rabbit',
1413 | 'raccoon',
1414 | 'race',
1415 | 'rack',
1416 | 'radar',
1417 | 'radio',
1418 | 'rail',
1419 | 'rain',
1420 | 'raise',
1421 | 'rally',
1422 | 'ramp',
1423 | 'ranch',
1424 | 'random',
1425 | 'range',
1426 | 'rapid',
1427 | 'rare',
1428 | 'rate',
1429 | 'rather',
1430 | 'raven',
1431 | 'raw',
1432 | 'razor',
1433 | 'ready',
1434 | 'real',
1435 | 'reason',
1436 | 'rebel',
1437 | 'rebuild',
1438 | 'recall',
1439 | 'receive',
1440 | 'recipe',
1441 | 'record',
1442 | 'recycle',
1443 | 'reduce',
1444 | 'reflect',
1445 | 'reform',
1446 | 'refuse',
1447 | 'region',
1448 | 'regret',
1449 | 'regular',
1450 | 'reject',
1451 | 'relax',
1452 | 'release',
1453 | 'relief',
1454 | 'rely',
1455 | 'remain',
1456 | 'remember',
1457 | 'remind',
1458 | 'remove',
1459 | 'render',
1460 | 'renew',
1461 | 'rent',
1462 | 'reopen',
1463 | 'repair',
1464 | 'repeat',
1465 | 'replace',
1466 | 'report',
1467 | 'require',
1468 | 'rescue',
1469 | 'resemble',
1470 | 'resist',
1471 | 'resource',
1472 | 'response',
1473 | 'result',
1474 | 'retire',
1475 | 'retreat',
1476 | 'return',
1477 | 'reunion',
1478 | 'reveal',
1479 | 'review',
1480 | 'reward',
1481 | 'rhythm',
1482 | 'rib',
1483 | 'ribbon',
1484 | 'rice',
1485 | 'rich',
1486 | 'ride',
1487 | 'ridge',
1488 | 'rifle',
1489 | 'right',
1490 | 'rigid',
1491 | 'ring',
1492 | 'riot',
1493 | 'ripple',
1494 | 'risk',
1495 | 'ritual',
1496 | 'rival',
1497 | 'river',
1498 | 'road',
1499 | 'roast',
1500 | 'robot',
1501 | 'robust',
1502 | 'rocket',
1503 | 'romance',
1504 | 'roof',
1505 | 'rookie',
1506 | 'room',
1507 | 'rose',
1508 | 'rotate',
1509 | 'rough',
1510 | 'round',
1511 | 'route',
1512 | 'royal',
1513 | 'rubber',
1514 | 'rude',
1515 | 'rug',
1516 | 'rule',
1517 | 'run',
1518 | 'runway',
1519 | 'rural',
1520 | 'sad',
1521 | 'saddle',
1522 | 'sadness',
1523 | 'safe',
1524 | 'sail',
1525 | 'salad',
1526 | 'salmon',
1527 | 'salon',
1528 | 'salt',
1529 | 'salute',
1530 | 'same',
1531 | 'sample',
1532 | 'sand',
1533 | 'satisfy',
1534 | 'satoshi',
1535 | 'sauce',
1536 | 'sausage',
1537 | 'save',
1538 | 'say',
1539 | 'scale',
1540 | 'scan',
1541 | 'scare',
1542 | 'scatter',
1543 | 'scene',
1544 | 'scheme',
1545 | 'school',
1546 | 'science',
1547 | 'scissors',
1548 | 'scorpion',
1549 | 'scout',
1550 | 'scrap',
1551 | 'screen',
1552 | 'script',
1553 | 'scrub',
1554 | 'sea',
1555 | 'search',
1556 | 'season',
1557 | 'seat',
1558 | 'second',
1559 | 'secret',
1560 | 'section',
1561 | 'security',
1562 | 'seed',
1563 | 'seek',
1564 | 'segment',
1565 | 'select',
1566 | 'sell',
1567 | 'seminar',
1568 | 'senior',
1569 | 'sense',
1570 | 'sentence',
1571 | 'series',
1572 | 'service',
1573 | 'session',
1574 | 'settle',
1575 | 'setup',
1576 | 'seven',
1577 | 'shadow',
1578 | 'shaft',
1579 | 'shallow',
1580 | 'share',
1581 | 'shed',
1582 | 'shell',
1583 | 'sheriff',
1584 | 'shield',
1585 | 'shift',
1586 | 'shine',
1587 | 'ship',
1588 | 'shiver',
1589 | 'shock',
1590 | 'shoe',
1591 | 'shoot',
1592 | 'shop',
1593 | 'short',
1594 | 'shoulder',
1595 | 'shove',
1596 | 'shrimp',
1597 | 'shrug',
1598 | 'shuffle',
1599 | 'shy',
1600 | 'sibling',
1601 | 'sick',
1602 | 'side',
1603 | 'siege',
1604 | 'sight',
1605 | 'sign',
1606 | 'silent',
1607 | 'silk',
1608 | 'silly',
1609 | 'silver',
1610 | 'similar',
1611 | 'simple',
1612 | 'since',
1613 | 'sing',
1614 | 'siren',
1615 | 'sister',
1616 | 'situate',
1617 | 'six',
1618 | 'size',
1619 | 'skate',
1620 | 'sketch',
1621 | 'ski',
1622 | 'skill',
1623 | 'skin',
1624 | 'skirt',
1625 | 'skull',
1626 | 'slab',
1627 | 'slam',
1628 | 'sleep',
1629 | 'slender',
1630 | 'slice',
1631 | 'slide',
1632 | 'slight',
1633 | 'slim',
1634 | 'slogan',
1635 | 'slot',
1636 | 'slow',
1637 | 'slush',
1638 | 'small',
1639 | 'smart',
1640 | 'smile',
1641 | 'smoke',
1642 | 'smooth',
1643 | 'snack',
1644 | 'snake',
1645 | 'snap',
1646 | 'sniff',
1647 | 'snow',
1648 | 'soap',
1649 | 'soccer',
1650 | 'social',
1651 | 'sock',
1652 | 'soda',
1653 | 'soft',
1654 | 'solar',
1655 | 'soldier',
1656 | 'solid',
1657 | 'solution',
1658 | 'solve',
1659 | 'someone',
1660 | 'song',
1661 | 'soon',
1662 | 'sorry',
1663 | 'sort',
1664 | 'soul',
1665 | 'sound',
1666 | 'soup',
1667 | 'source',
1668 | 'south',
1669 | 'space',
1670 | 'spare',
1671 | 'spatial',
1672 | 'spawn',
1673 | 'speak',
1674 | 'special',
1675 | 'speed',
1676 | 'spell',
1677 | 'spend',
1678 | 'sphere',
1679 | 'spice',
1680 | 'spider',
1681 | 'spike',
1682 | 'spin',
1683 | 'spirit',
1684 | 'split',
1685 | 'spoil',
1686 | 'sponsor',
1687 | 'spoon',
1688 | 'sport',
1689 | 'spot',
1690 | 'spray',
1691 | 'spread',
1692 | 'spring',
1693 | 'spy',
1694 | 'square',
1695 | 'squeeze',
1696 | 'squirrel',
1697 | 'stable',
1698 | 'stadium',
1699 | 'staff',
1700 | 'stage',
1701 | 'stairs',
1702 | 'stamp',
1703 | 'stand',
1704 | 'start',
1705 | 'state',
1706 | 'stay',
1707 | 'steak',
1708 | 'steel',
1709 | 'stem',
1710 | 'step',
1711 | 'stereo',
1712 | 'stick',
1713 | 'still',
1714 | 'sting',
1715 | 'stock',
1716 | 'stomach',
1717 | 'stone',
1718 | 'stool',
1719 | 'story',
1720 | 'stove',
1721 | 'strategy',
1722 | 'street',
1723 | 'strike',
1724 | 'strong',
1725 | 'struggle',
1726 | 'student',
1727 | 'stuff',
1728 | 'stumble',
1729 | 'style',
1730 | 'subject',
1731 | 'submit',
1732 | 'subway',
1733 | 'success',
1734 | 'such',
1735 | 'sudden',
1736 | 'suffer',
1737 | 'sugar',
1738 | 'suggest',
1739 | 'suit',
1740 | 'summer',
1741 | 'sun',
1742 | 'sunny',
1743 | 'sunset',
1744 | 'super',
1745 | 'supply',
1746 | 'supreme',
1747 | 'sure',
1748 | 'surface',
1749 | 'surge',
1750 | 'surprise',
1751 | 'surround',
1752 | 'survey',
1753 | 'suspect',
1754 | 'sustain',
1755 | 'swallow',
1756 | 'swamp',
1757 | 'swap',
1758 | 'swarm',
1759 | 'swear',
1760 | 'sweet',
1761 | 'swift',
1762 | 'swim',
1763 | 'swing',
1764 | 'switch',
1765 | 'sword',
1766 | 'symbol',
1767 | 'symptom',
1768 | 'syrup',
1769 | 'system',
1770 | 'table',
1771 | 'tackle',
1772 | 'tag',
1773 | 'tail',
1774 | 'talent',
1775 | 'talk',
1776 | 'tank',
1777 | 'tape',
1778 | 'target',
1779 | 'task',
1780 | 'taste',
1781 | 'tattoo',
1782 | 'taxi',
1783 | 'teach',
1784 | 'team',
1785 | 'tell',
1786 | 'ten',
1787 | 'tenant',
1788 | 'tennis',
1789 | 'tent',
1790 | 'term',
1791 | 'test',
1792 | 'text',
1793 | 'thank',
1794 | 'that',
1795 | 'theme',
1796 | 'then',
1797 | 'theory',
1798 | 'there',
1799 | 'they',
1800 | 'thing',
1801 | 'this',
1802 | 'thought',
1803 | 'three',
1804 | 'thrive',
1805 | 'throw',
1806 | 'thumb',
1807 | 'thunder',
1808 | 'ticket',
1809 | 'tide',
1810 | 'tiger',
1811 | 'tilt',
1812 | 'timber',
1813 | 'time',
1814 | 'tiny',
1815 | 'tip',
1816 | 'tired',
1817 | 'tissue',
1818 | 'title',
1819 | 'toast',
1820 | 'tobacco',
1821 | 'today',
1822 | 'toddler',
1823 | 'toe',
1824 | 'together',
1825 | 'toilet',
1826 | 'token',
1827 | 'tomato',
1828 | 'tomorrow',
1829 | 'tone',
1830 | 'tongue',
1831 | 'tonight',
1832 | 'tool',
1833 | 'tooth',
1834 | 'top',
1835 | 'topic',
1836 | 'topple',
1837 | 'torch',
1838 | 'tornado',
1839 | 'tortoise',
1840 | 'toss',
1841 | 'total',
1842 | 'tourist',
1843 | 'toward',
1844 | 'tower',
1845 | 'town',
1846 | 'toy',
1847 | 'track',
1848 | 'trade',
1849 | 'traffic',
1850 | 'tragic',
1851 | 'train',
1852 | 'transfer',
1853 | 'trap',
1854 | 'trash',
1855 | 'travel',
1856 | 'tray',
1857 | 'treat',
1858 | 'tree',
1859 | 'trend',
1860 | 'trial',
1861 | 'tribe',
1862 | 'trick',
1863 | 'trigger',
1864 | 'trim',
1865 | 'trip',
1866 | 'trophy',
1867 | 'trouble',
1868 | 'truck',
1869 | 'true',
1870 | 'truly',
1871 | 'trumpet',
1872 | 'trust',
1873 | 'truth',
1874 | 'try',
1875 | 'tube',
1876 | 'tuition',
1877 | 'tumble',
1878 | 'tuna',
1879 | 'tunnel',
1880 | 'turkey',
1881 | 'turn',
1882 | 'turtle',
1883 | 'twelve',
1884 | 'twenty',
1885 | 'twice',
1886 | 'twin',
1887 | 'twist',
1888 | 'two',
1889 | 'type',
1890 | 'typical',
1891 | 'ugly',
1892 | 'umbrella',
1893 | 'unable',
1894 | 'unaware',
1895 | 'uncle',
1896 | 'uncover',
1897 | 'under',
1898 | 'undo',
1899 | 'unfair',
1900 | 'unfold',
1901 | 'unhappy',
1902 | 'uniform',
1903 | 'unique',
1904 | 'unit',
1905 | 'universe',
1906 | 'unknown',
1907 | 'unlock',
1908 | 'until',
1909 | 'unusual',
1910 | 'unveil',
1911 | 'update',
1912 | 'upgrade',
1913 | 'uphold',
1914 | 'upon',
1915 | 'upper',
1916 | 'upset',
1917 | 'urban',
1918 | 'urge',
1919 | 'usage',
1920 | 'use',
1921 | 'used',
1922 | 'useful',
1923 | 'useless',
1924 | 'usual',
1925 | 'utility',
1926 | 'vacant',
1927 | 'vacuum',
1928 | 'vague',
1929 | 'valid',
1930 | 'valley',
1931 | 'valve',
1932 | 'van',
1933 | 'vanish',
1934 | 'vapor',
1935 | 'various',
1936 | 'vast',
1937 | 'vault',
1938 | 'vehicle',
1939 | 'velvet',
1940 | 'vendor',
1941 | 'venture',
1942 | 'venue',
1943 | 'verb',
1944 | 'verify',
1945 | 'version',
1946 | 'very',
1947 | 'vessel',
1948 | 'veteran',
1949 | 'viable',
1950 | 'vibrant',
1951 | 'vicious',
1952 | 'victory',
1953 | 'video',
1954 | 'view',
1955 | 'village',
1956 | 'vintage',
1957 | 'violin',
1958 | 'virtual',
1959 | 'virus',
1960 | 'visa',
1961 | 'visit',
1962 | 'visual',
1963 | 'vital',
1964 | 'vivid',
1965 | 'vocal',
1966 | 'voice',
1967 | 'void',
1968 | 'volcano',
1969 | 'volume',
1970 | 'vote',
1971 | 'voyage',
1972 | 'wage',
1973 | 'wagon',
1974 | 'wait',
1975 | 'walk',
1976 | 'wall',
1977 | 'walnut',
1978 | 'want',
1979 | 'warfare',
1980 | 'warm',
1981 | 'warrior',
1982 | 'wash',
1983 | 'wasp',
1984 | 'waste',
1985 | 'water',
1986 | 'wave',
1987 | 'way',
1988 | 'wealth',
1989 | 'weapon',
1990 | 'wear',
1991 | 'weasel',
1992 | 'weather',
1993 | 'web',
1994 | 'wedding',
1995 | 'weekend',
1996 | 'weird',
1997 | 'welcome',
1998 | 'west',
1999 | 'wet',
2000 | 'whale',
2001 | 'what',
2002 | 'wheat',
2003 | 'wheel',
2004 | 'when',
2005 | 'where',
2006 | 'whip',
2007 | 'whisper',
2008 | 'wide',
2009 | 'width',
2010 | 'wife',
2011 | 'wild',
2012 | 'will',
2013 | 'win',
2014 | 'window',
2015 | 'wine',
2016 | 'wing',
2017 | 'wink',
2018 | 'winner',
2019 | 'winter',
2020 | 'wire',
2021 | 'wisdom',
2022 | 'wise',
2023 | 'wish',
2024 | 'witness',
2025 | 'wolf',
2026 | 'woman',
2027 | 'wonder',
2028 | 'wood',
2029 | 'wool',
2030 | 'word',
2031 | 'work',
2032 | 'world',
2033 | 'worry',
2034 | 'worth',
2035 | 'wrap',
2036 | 'wreck',
2037 | 'wrestle',
2038 | 'wrist',
2039 | 'write',
2040 | 'wrong',
2041 | 'yard',
2042 | 'year',
2043 | 'yellow',
2044 | 'you',
2045 | 'young',
2046 | 'youth',
2047 | 'zebra',
2048 | 'zero',
2049 | 'zone',
2050 | 'zoo'
2051 | ];
2052 |
--------------------------------------------------------------------------------
/src/bip39-wordlists/index.ts:
--------------------------------------------------------------------------------
1 |
2 | import english from './english';
3 |
4 |
5 | export {
6 | english,
7 | english as EN,
8 | english as default,
9 | };
10 |
--------------------------------------------------------------------------------
/src/crypto/crypto-node.ts:
--------------------------------------------------------------------------------
1 |
2 | // Only supported in Node.js >= 15
3 |
4 | import { webcrypto } from 'crypto';
5 |
6 | export default webcrypto;
7 |
--------------------------------------------------------------------------------
/src/crypto/crypto-web.ts:
--------------------------------------------------------------------------------
1 |
2 | // Only supported in browsers
3 | export default self.crypto;
4 |
--------------------------------------------------------------------------------
/src/functions/common.test.ts:
--------------------------------------------------------------------------------
1 |
2 | import { TextEncoder } from 'util';
3 |
4 | import { hmacSha512, pbkdf2Sha512, stringToIntArray } from './common';
5 |
6 |
7 | describe('isBasicSeed()', () => {
8 | it.todo('should work');
9 | });
10 |
11 | describe('isPasswordSeed()', () => {
12 | it.todo('should work');
13 | });
14 |
15 | describe('mnemonicToEntropy()', () => {
16 | it.todo('should work');
17 | });
18 |
19 | describe('pbkdf2Sha512()', () => {
20 |
21 | const cases: Array<[string, string, number, string]> = [
22 | ['tutturu', 'blabla', 10, '3817ff5ce29ec89db7a591b3ec8b053088731a7c967665b6dac9203bc1d75674800a2846c17b6e417269d787cff0b5c23aba5aab6e76ffde441633db1f2bf87b'],
23 | ['gizmodo_lopez', 'hashimoto', 1000, '308f90aab4434b62e13ff593b5472ee8ae3672e82fe08dfe48a0a6625a9d20304134186cf9889c8b8f135a0f9d5392ed0875fcd1e50c53d54b72dc3001f48377'],
24 | ];
25 |
26 | for (const [key, salt, iterations, expectedHex] of cases) {
27 | it(`should generate correct key (${key}/${salt}/${iterations})`, async () => {
28 | const keyBuffer = stringToIntArray(key);
29 | const result = await pbkdf2Sha512(keyBuffer, salt, iterations);
30 | expect(bufferToHex(result.buffer)).toEqual(expectedHex);
31 | });
32 | }
33 |
34 | });
35 |
36 | describe('hmacSha512()', () => {
37 |
38 | const cases = [
39 | ['mustafa', 'carrot', '651df9349efe6bd60e33ab842eed03ca5816e0248982af6cfb42db5af28beb204524cf96e33d405cecb3c9e05a6ebf23635bc32591b828bd26e673995d511d06'],
40 | ['gimmler', 'witcher', '17389339d22f8554f4ab07d30cede0c67079c55ae9dee19709f3b4ac4a9d9b380016f76da860d3b4757cbe9dc8c0ceeda07c42fd4fb673414c3af458cd1c3eb0'],
41 | ['1', '', '70cf5c654a3335e493c263498b849b1aa425012914f8b5e77f4b7b7408ad207db9758f7c431887aa8f4885097e3bc032ee78238157c2ad43e900b69c60aee71e'],
42 | ];
43 |
44 | for (const [phrase, password, expectedHex] of cases) {
45 | it(`should generate correct HMAC (${phrase}/${password || '""'})`, async () => {
46 | const buffer = await hmacSha512(phrase, password);
47 | expect(bufferToHex(buffer)).toEqual(expectedHex);
48 | });
49 | }
50 |
51 | });
52 |
53 | describe('stringToBuffer()', () => {
54 |
55 | it('should convert string to buffer', () => {
56 |
57 | const buffer = stringToIntArray('hello');
58 |
59 | const expected = (new TextEncoder()).encode('hello');
60 |
61 | expect(buffer).toEqual(expected);
62 |
63 | });
64 |
65 | it('should throw when incorrect size specified', () => {
66 | expect(() => stringToIntArray('hello', 5))
67 | .toThrow('Incorrect size');
68 |
69 | expect(() => stringToIntArray('hello', 0))
70 | .toThrow('Incorrect size');
71 |
72 | expect(() => stringToIntArray('hello', -5))
73 | .toThrow('Incorrect size');
74 |
75 | });
76 |
77 | });
78 |
79 |
80 | /**
81 | * Take from: https://stackoverflow.com/a/40031979/1056679
82 | */
83 | function bufferToHex(buffer) {
84 | return ([...new Uint8Array(buffer)]
85 | .map(x => x.toString(16).padStart(2, '0'))
86 | .join('')
87 | );
88 | }
89 |
--------------------------------------------------------------------------------
/src/functions/common.ts:
--------------------------------------------------------------------------------
1 |
2 | import crypto from '../crypto/crypto-node';
3 |
4 |
5 | export const PBKDF_ITERATIONS = 100000;
6 |
7 |
8 | export async function isBasicSeed(entropy: ArrayBuffer): Promise {
9 | const seed = await pbkdf2Sha512(entropy, 'TON seed version', Math.max(1, Math.floor(PBKDF_ITERATIONS / 256)));
10 | return seed[0] == 0;
11 | }
12 |
13 |
14 | export async function isPasswordSeed(entropy: ArrayBuffer): Promise {
15 | const seed = await pbkdf2Sha512(entropy, 'TON fast seed version', 1);
16 | return seed[0] == 1;
17 | }
18 |
19 |
20 | export async function mnemonicToEntropy(mnemonicArray: string[], password: string = ''): Promise {
21 | const mnemonicPhrase = mnemonicArray.join(' ');
22 | return await hmacSha512(mnemonicPhrase, password);
23 | }
24 |
25 |
26 | export async function pbkdf2Sha512(key: ArrayBuffer, salt: string, iterations: number): Promise {
27 | const saltBuffer = stringToIntArray(salt).buffer;
28 | const pbkdf2_key = await crypto.subtle.importKey(
29 | 'raw',
30 | key,
31 | {name: 'PBKDF2'},
32 | false,
33 | ['deriveBits']
34 | );
35 | const derivedBits = await crypto.subtle.deriveBits(
36 | {name: 'PBKDF2', hash: 'SHA-512', salt: saltBuffer, iterations: iterations},
37 | pbkdf2_key,
38 | 512
39 | );
40 | return new Uint8Array(derivedBits);
41 | }
42 |
43 |
44 | export async function hmacSha512(phrase: string, password: string): Promise {
45 | const phraseBuffer = stringToIntArray(phrase).buffer;
46 | const passwordBuffer = password.length ? stringToIntArray(password).buffer : new ArrayBuffer(0);
47 | const hmacAlgo = {name: 'HMAC', hash: 'SHA-512'};
48 | const hmacKey = await crypto.subtle.importKey(
49 | 'raw',
50 | phraseBuffer,
51 | hmacAlgo,
52 | false,
53 | ['sign']
54 | );
55 | return await crypto.subtle.sign(hmacAlgo, hmacKey, passwordBuffer);
56 | }
57 |
58 |
59 | export function stringToIntArray(str: string, size: number = 1): Uint8Array {
60 |
61 | let buffer;
62 | let bufferView;
63 |
64 | switch (size) {
65 | case 1:
66 | buffer = new ArrayBuffer(str.length);
67 | bufferView = new Uint8Array(buffer);
68 | break;
69 | case 2:
70 | buffer = new ArrayBuffer(str.length * 2);
71 | bufferView = new Uint16Array(buffer);
72 | break;
73 | case 4:
74 | buffer = new ArrayBuffer(str.length * 4);
75 | bufferView = new Uint32Array(buffer);
76 | break;
77 | default:
78 | throw new Error(`Incorrect size specified: ${size}`);
79 | }
80 |
81 | for (let i = 0, strLen = str.length; i < strLen; i++) {
82 | bufferView[i] = str.charCodeAt(i);
83 | }
84 |
85 | return new Uint8Array(bufferView.buffer);
86 |
87 | }
88 |
--------------------------------------------------------------------------------
/src/functions/generate-mnemonic.test.ts:
--------------------------------------------------------------------------------
1 |
2 | describe('generateMnemonic()', () => {
3 |
4 | it.todo('should work');
5 |
6 | });
7 |
--------------------------------------------------------------------------------
/src/functions/generate-mnemonic.ts:
--------------------------------------------------------------------------------
1 |
2 | import crypto from '../crypto/crypto-node';
3 | import { default as defaultWordlist } from '../bip39-wordlists';
4 | import { isBasicSeed, mnemonicToEntropy } from './common';
5 | import { isPasswordNeeded } from './is-password-needed';
6 |
7 |
8 | export async function generateMnemonic(
9 | wordsCount: number = 24,
10 | password: string = '',
11 | wordlist: string[] = defaultWordlist
12 |
13 | ): Promise {
14 |
15 | let c = 0;
16 | let mnemonicArray = [];
17 |
18 | while (true) {
19 | c += 1;
20 | mnemonicArray = [];
21 | const rnd = crypto.getRandomValues(new Uint16Array(wordsCount));
22 | for (let i = 0; i < wordsCount; i++) {
23 | mnemonicArray.push(wordlist[rnd[i] & 2047]); // We loose 5 out of 16 bits of entropy here, good enough
24 | }
25 | if (password.length > 0) {
26 | if (!await isPasswordNeeded(mnemonicArray))
27 | continue;
28 | }
29 | if (!(await isBasicSeed(await mnemonicToEntropy(mnemonicArray, password)))) {
30 | continue;
31 | }
32 | break;
33 | }
34 |
35 | return mnemonicArray;
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/functions/is-password-needed.test.ts:
--------------------------------------------------------------------------------
1 |
2 | describe('isPasswordNeeded()', () => {
3 |
4 | it.todo('should work');
5 |
6 | });
7 |
--------------------------------------------------------------------------------
/src/functions/is-password-needed.ts:
--------------------------------------------------------------------------------
1 |
2 | import { isBasicSeed, isPasswordSeed, mnemonicToEntropy } from './common';
3 |
4 |
5 | export async function isPasswordNeeded(mnemonicArray: string[]): Promise {
6 | // password mnemonic (without password) should be password seed, but not basic seed
7 | const entropy = await mnemonicToEntropy(mnemonicArray, '');
8 | return (
9 | (await isPasswordSeed(entropy)) && !(await isBasicSeed(entropy))
10 | );
11 | }
12 |
--------------------------------------------------------------------------------
/src/functions/mnemonic-to-key-pair.test.ts:
--------------------------------------------------------------------------------
1 |
2 | describe('mnemonicToKeyPair()', () => {
3 |
4 | it.todo('should work');
5 |
6 | });
7 |
--------------------------------------------------------------------------------
/src/functions/mnemonic-to-key-pair.ts:
--------------------------------------------------------------------------------
1 |
2 | import nacl from 'tweetnacl';
3 |
4 | import { mnemonicToSeed } from './mnemonic-to-seed';
5 |
6 |
7 | export interface KeyPair {
8 | publicKey: Uint8Array;
9 | secretKey: Uint8Array;
10 | }
11 |
12 |
13 | export async function mnemonicToKeyPair(mnemonicArray: string[], password: string = ''): Promise {
14 | const seed = await mnemonicToSeed(mnemonicArray, password);
15 | return nacl.sign.keyPair.fromSeed(seed);
16 | }
17 |
--------------------------------------------------------------------------------
/src/functions/mnemonic-to-seed.test.ts:
--------------------------------------------------------------------------------
1 |
2 | describe('mnemonicToSeed()', () => {
3 |
4 | it.todo('should work');
5 |
6 | });
7 |
--------------------------------------------------------------------------------
/src/functions/mnemonic-to-seed.ts:
--------------------------------------------------------------------------------
1 |
2 | import { mnemonicToEntropy, pbkdf2Sha512, PBKDF_ITERATIONS } from './common';
3 |
4 |
5 | export async function mnemonicToSeed(
6 | mnemonicArray: string[],
7 | password: string = ''
8 |
9 | ): Promise {
10 |
11 | const entropy = await mnemonicToEntropy(mnemonicArray, password);
12 |
13 | const seed = await pbkdf2Sha512(entropy, 'TON default seed', PBKDF_ITERATIONS);
14 |
15 | return seed.slice(0, 32);
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/functions/validate-mnemonic.test.ts:
--------------------------------------------------------------------------------
1 |
2 | describe('validateMnemonic()', () => {
3 |
4 | it.todo('should work');
5 |
6 | });
7 |
--------------------------------------------------------------------------------
/src/functions/validate-mnemonic.ts:
--------------------------------------------------------------------------------
1 |
2 | import { default as defaultWordlist } from '../bip39-wordlists';
3 | import { isBasicSeed, mnemonicToEntropy } from './common';
4 | import { isPasswordNeeded } from './is-password-needed';
5 |
6 |
7 | export async function validateMnemonic(
8 | mnemonicArray: string[],
9 | password: string = '',
10 | wordlist: string[] = defaultWordlist
11 |
12 | ): Promise {
13 |
14 | for (let word of mnemonicArray) {
15 | if (wordlist.indexOf(word) === -1) {
16 | return false;
17 | }
18 | }
19 |
20 | if (password.length > 0) {
21 | if (!(await isPasswordNeeded(mnemonicArray))) {
22 | return false;
23 | }
24 | }
25 |
26 | return await isBasicSeed(
27 | await mnemonicToEntropy(mnemonicArray, password)
28 | );
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 |
2 | export { generateMnemonic } from './functions/generate-mnemonic';
3 | export { isPasswordNeeded } from './functions/is-password-needed';
4 | export { mnemonicToKeyPair, KeyPair } from './functions/mnemonic-to-key-pair';
5 | export { mnemonicToSeed } from './functions/mnemonic-to-seed';
6 | export { validateMnemonic } from './functions/validate-mnemonic';
7 |
8 | export * as wordlists from './bip39-wordlists';
9 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "moduleResolution": "node",
5 | "target": "ES2017",
6 | "lib": [
7 | "ESNext"
8 | ],
9 | "skipLibCheck": true,
10 | "esModuleInterop": true,
11 | "typeRoots": [
12 | "node_modules/@types",
13 | "types"
14 | ]
15 | },
16 | "files": [
17 | "webpack.config.ts"
18 | ],
19 | "exclude": [
20 | "node_modules/"
21 | ]
22 | }
23 |
--------------------------------------------------------------------------------
/tsconfig.lib.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs",
4 | "moduleResolution": "node",
5 | "target": "ES2017",
6 | "rootDir": "src/",
7 | "outDir": "dist/",
8 | "declarationDir": "dist/types/",
9 | "removeComments": true,
10 | "lib": [
11 | "ESNext",
12 | "DOM"
13 | ],
14 | "skipLibCheck": true,
15 | "sourceMap": true,
16 | "esModuleInterop": true,
17 | "typeRoots": [
18 | "node_modules/@types",
19 | "types"
20 | ],
21 | "noEmitOnError": true,
22 | "declaration": true,
23 | "emitDeclarationOnly": true
24 | },
25 | "include": [
26 | "src/"
27 | ],
28 | "exclude": [
29 | "node_modules/",
30 | "**/*.test.ts"
31 | ]
32 | }
33 |
--------------------------------------------------------------------------------
/tsconfig.test.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.lib.json",
3 | "include": [
4 | "src/"
5 | ],
6 | "exclude": [
7 | "node_modules/"
8 | ]
9 | }
10 |
--------------------------------------------------------------------------------
/types/webcrypto/index.d.ts:
--------------------------------------------------------------------------------
1 |
2 | declare module 'crypto' {
3 |
4 | type IntTypedArray = (
5 | | Int8Array
6 | | Uint8Array
7 | | Int16Array
8 | | Uint16Array
9 | | Int32Array
10 | | Uint32Array
11 | );
12 |
13 | namespace webcrypto {
14 |
15 | const subtle: SubtleCrypto;
16 |
17 | function getRandomValues(
18 | typedArray: IntTypedArray
19 |
20 | ): IntTypedArray;
21 |
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/webpack.config.ts:
--------------------------------------------------------------------------------
1 |
2 | const path = require('path');
3 |
4 | import { NormalModuleReplacementPlugin, Configuration as WebpackConfig } from 'webpack';
5 | import { merge } from 'webpack-merge';
6 | import nodeExternals from 'webpack-node-externals';
7 | import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
8 |
9 |
10 | export default function configureWebpack(env): WebpackConfig[] {
11 |
12 | // Getting Webpack CLI args, or falling back to defaults
13 | const {
14 | mode = (process.env.NODE_ENV || 'development'),
15 |
16 | } = env;
17 |
18 | const baseConfig = {
19 | mode,
20 | entry: './src/index.ts',
21 | devtool: 'source-map',
22 | output: {
23 | filename: 'index.js',
24 | },
25 | resolve: {
26 | extensions: ['.ts'],
27 | },
28 | module: {
29 | rules: [
30 | {
31 | test: /\.ts$/,
32 | exclude: /node_modules/,
33 | use: {
34 | loader: 'babel-loader',
35 | options: {
36 | presets: ['@babel/preset-typescript'],
37 | plugins: ['@babel/plugin-transform-runtime']
38 | }
39 | },
40 | },
41 | ],
42 | },
43 | plugins: [
44 | new ForkTsCheckerWebpackPlugin({
45 | typescript: {
46 | configFile: path.resolve(__dirname, 'tsconfig.lib.json'),
47 | },
48 | }),
49 | ]
50 | };
51 |
52 | /**
53 | * Browser-specific config.
54 | */
55 | const webConfig = merge(baseConfig, {
56 | name: 'web',
57 | target: 'web',
58 | output: {
59 | library: {
60 | type: 'umd',
61 | name: {
62 | root: ['TonWeb', 'mnemonic'],
63 | amd: 'tonweb-mnemonic',
64 | commonjs: 'tonweb-mnemonic',
65 | },
66 | },
67 | path: path.resolve(__dirname, 'dist/web'),
68 | },
69 | plugins: [
70 | // Using native "webcrypto" utilities
71 | new NormalModuleReplacementPlugin(
72 | /crypto\/crypto-node/,
73 | path.resolve(__dirname, 'src/crypto/crypto-web.ts')
74 | )
75 | ],
76 | });
77 |
78 | /**
79 | * Node-specific config.
80 | */
81 | const nodeConfig = merge(baseConfig, {
82 | name: 'node',
83 | target: 'node',
84 | output: {
85 | library: {
86 | type: 'commonjs2',
87 | },
88 | path: path.resolve(__dirname, 'dist/node'),
89 | },
90 | externalsPresets: {
91 | node: true,
92 | },
93 | externals: [nodeExternals()],
94 | optimization: {
95 | minimize: false,
96 | },
97 | });
98 |
99 | // Returning multiple configs
100 | // for parallel builds
101 | return [
102 | nodeConfig,
103 | webConfig,
104 | ];
105 |
106 | }
107 |
--------------------------------------------------------------------------------