mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-06-23 12:01:08 +00:00
chore: update to version 14.0.11 and align website URLs
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { stringToU8a } from '@pezkuwi/util';
|
||||
import { bip39ToMiniSecret, isReady } from '@pezkuwi/wasm-crypto';
|
||||
import { pbkdf2Encode } from '../pbkdf2/index.js';
|
||||
import { mnemonicToEntropy } from './toEntropy.js';
|
||||
import { mnemonicValidate } from './validate.js';
|
||||
export function mnemonicToMiniSecret(mnemonic, password = '', wordlist, onlyJs) {
|
||||
if (!mnemonicValidate(mnemonic, wordlist, onlyJs)) {
|
||||
throw new Error('Invalid bip39 mnemonic specified');
|
||||
}
|
||||
else if (!wordlist && !onlyJs && isReady()) {
|
||||
return bip39ToMiniSecret(mnemonic, password);
|
||||
}
|
||||
const entropy = mnemonicToEntropy(mnemonic, wordlist);
|
||||
const salt = stringToU8a(`mnemonic${password}`);
|
||||
// return the first 32 bytes as the seed
|
||||
return pbkdf2Encode(entropy, salt).password.slice(0, 32);
|
||||
}
|
||||
Reference in New Issue
Block a user