index.d.ts 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * Generate x random words. Uses Cryptographically-Secure Random Number Generator.
  3. * @param wordlist imported wordlist for specific language
  4. * @param strength mnemonic strength 128-256 bits
  5. * @example
  6. * generateMnemonic(wordlist, 128)
  7. * // 'legal winner thank year wave sausage worth useful legal winner thank yellow'
  8. */
  9. export declare function generateMnemonic(wordlist: string[], strength?: number): string;
  10. /**
  11. * Reversible: Converts mnemonic string to raw entropy in form of byte array.
  12. * @param mnemonic 12-24 words
  13. * @param wordlist imported wordlist for specific language
  14. * @example
  15. * const mnem = 'legal winner thank year wave sausage worth useful legal winner thank yellow';
  16. * mnemonicToEntropy(mnem, wordlist)
  17. * // Produces
  18. * new Uint8Array([
  19. * 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
  20. * 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f
  21. * ])
  22. */
  23. export declare function mnemonicToEntropy(mnemonic: string, wordlist: string[]): Uint8Array;
  24. /**
  25. * Reversible: Converts raw entropy in form of byte array to mnemonic string.
  26. * @param entropy byte array
  27. * @param wordlist imported wordlist for specific language
  28. * @returns 12-24 words
  29. * @example
  30. * const ent = new Uint8Array([
  31. * 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
  32. * 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f
  33. * ]);
  34. * entropyToMnemonic(ent, wordlist);
  35. * // 'legal winner thank year wave sausage worth useful legal winner thank yellow'
  36. */
  37. export declare function entropyToMnemonic(entropy: Uint8Array, wordlist: string[]): string;
  38. /**
  39. * Validates mnemonic for being 12-24 words contained in `wordlist`.
  40. */
  41. export declare function validateMnemonic(mnemonic: string, wordlist: string[]): boolean;
  42. /**
  43. * Irreversible: Uses KDF to derive 64 bytes of key data from mnemonic + optional password.
  44. * @param mnemonic 12-24 words
  45. * @param passphrase string that will additionally protect the key
  46. * @returns 64 bytes of key data
  47. * @example
  48. * const mnem = 'legal winner thank year wave sausage worth useful legal winner thank yellow';
  49. * await mnemonicToSeed(mnem, 'password');
  50. * // new Uint8Array([...64 bytes])
  51. */
  52. export declare function mnemonicToSeed(mnemonic: string, passphrase?: string): Promise<Uint8Array>;
  53. /**
  54. * Irreversible: Uses KDF to derive 64 bytes of key data from mnemonic + optional password.
  55. * @param mnemonic 12-24 words
  56. * @param passphrase string that will additionally protect the key
  57. * @returns 64 bytes of key data
  58. * @example
  59. * const mnem = 'legal winner thank year wave sausage worth useful legal winner thank yellow';
  60. * mnemonicToSeedSync(mnem, 'password');
  61. * // new Uint8Array([...64 bytes])
  62. */
  63. export declare function mnemonicToSeedSync(mnemonic: string, passphrase?: string): Uint8Array;
  64. //# sourceMappingURL=index.d.ts.map