Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@metamask/scure-bip39

Package Overview
Dependencies
Maintainers
8
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metamask/scure-bip39 - npm Package Compare versions

Comparing version 2.0.4 to 2.1.0

8

dist/index.d.ts

@@ -44,3 +44,4 @@ /**

* Irreversible: Uses KDF to derive 64 bytes of key data from mnemonic + optional password.
* @param mnemonic 12-24 words
* @param mnemonic 12-24 words (string | Uint8Array)
* @param wordlist array of 2048 words used to recover the mnemonic string from a Uint8Array
* @param passphrase string that will additionally protect the key

@@ -53,6 +54,7 @@ * @returns 64 bytes of key data

*/
export declare function mnemonicToSeed(mnemonic: string, passphrase?: string): Promise<Uint8Array>;
export declare function mnemonicToSeed(mnemonic: string | Uint8Array, wordlist: string[], passphrase?: string): Promise<Uint8Array>;
/**
* Irreversible: Uses KDF to derive 64 bytes of key data from mnemonic + optional password.
* @param mnemonic 12-24 words
* @param mnemonic 12-24 words (string | Uint8Array)
* @param wordlist array of 2048 words used to recover the mnemonic string from a Uint8Array
* @param passphrase string that will additionally protect the key

@@ -59,0 +61,0 @@ * @returns 64 bytes of key data

@@ -124,3 +124,4 @@ "use strict";

* Irreversible: Uses KDF to derive 64 bytes of key data from mnemonic + optional password.
* @param mnemonic 12-24 words
* @param mnemonic 12-24 words (string | Uint8Array)
* @param wordlist array of 2048 words used to recover the mnemonic string from a Uint8Array
* @param passphrase string that will additionally protect the key

@@ -133,4 +134,5 @@ * @returns 64 bytes of key data

*/
function mnemonicToSeed(mnemonic, passphrase = '') {
return (0, pbkdf2_1.pbkdf2Async)(sha512_1.sha512, normalize(mnemonic).nfkd, salt(passphrase), { c: 2048, dkLen: 64 });
function mnemonicToSeed(mnemonic, wordlist, passphrase = '') {
const encodedMnemonicUint8Array = encodeMnemonicForSeedDerivation(mnemonic, wordlist);
return (0, pbkdf2_1.pbkdf2Async)(sha512_1.sha512, encodedMnemonicUint8Array, salt(passphrase), { c: 2048, dkLen: 64 });
}

@@ -140,3 +142,4 @@ exports.mnemonicToSeed = mnemonicToSeed;

* Irreversible: Uses KDF to derive 64 bytes of key data from mnemonic + optional password.
* @param mnemonic 12-24 words
* @param mnemonic 12-24 words (string | Uint8Array)
* @param wordlist array of 2048 words used to recover the mnemonic string from a Uint8Array
* @param passphrase string that will additionally protect the key

@@ -150,13 +153,20 @@ * @returns 64 bytes of key data

function mnemonicToSeedSync(mnemonic, wordlist, passphrase = '') {
let mnemonicUint8Array;
const encodedMnemonicUint8Array = encodeMnemonicForSeedDerivation(mnemonic, wordlist);
return (0, pbkdf2_1.pbkdf2)(sha512_1.sha512, encodedMnemonicUint8Array, salt(passphrase), { c: 2048, dkLen: 64 });
}
exports.mnemonicToSeedSync = mnemonicToSeedSync;
/**
* Helper function to encode mnemonic passed either as a string or `Uint8Array` for deriving a seed/key with pbkdf2.
*/
function encodeMnemonicForSeedDerivation(mnemonic, wordlist) {
let encodedMnemonicUint8Array;
if (typeof mnemonic === 'string') {
mnemonicUint8Array = new TextEncoder().encode(normalize(mnemonic).nfkd);
encodedMnemonicUint8Array = new TextEncoder().encode(normalize(mnemonic).nfkd);
}
else {
mnemonicUint8Array = new TextEncoder().encode(Array.from(new Uint16Array(mnemonic.buffer))
encodedMnemonicUint8Array = new TextEncoder().encode(Array.from(new Uint16Array(mnemonic.buffer))
.map((i) => wordlist[i])
.join(' '));
}
return (0, pbkdf2_1.pbkdf2)(sha512_1.sha512, mnemonicUint8Array, salt(passphrase), { c: 2048, dkLen: 64 });
return encodedMnemonicUint8Array;
}
exports.mnemonicToSeedSync = mnemonicToSeedSync;
{
"name": "@metamask/scure-bip39",
"version": "2.0.4",
"version": "2.1.0",
"description": "MetaMask fork of @scure/bip39: a secure, audited & minimal implementation of BIP39 mnemonic phrases",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc