udpdate wallet function
This commit is contained in:
@@ -11,34 +11,13 @@ const ECPair = ECPairFactory(ecc);
|
||||
export default class WalletGenerator {
|
||||
static async generateMnemonic() {
|
||||
try {
|
||||
return bip39.generateMnemonic(256); // 24 words for maximum security
|
||||
return bip39.generateMnemonic(128); // 12 words for maximum security
|
||||
} catch (error) {
|
||||
console.error('Error generating mnemonic:', error);
|
||||
throw new Error('Failed to generate mnemonic');
|
||||
}
|
||||
}
|
||||
|
||||
static async encryptMnemonic(mnemonic, userId) {
|
||||
try {
|
||||
const key = process.env.ENCRYPTION_KEY || 'default-key-12345';
|
||||
return CryptoJS.AES.encrypt(mnemonic, key + userId.toString()).toString();
|
||||
} catch (error) {
|
||||
console.error('Error encrypting mnemonic:', error);
|
||||
throw new Error('Failed to encrypt mnemonic');
|
||||
}
|
||||
}
|
||||
|
||||
static async decryptMnemonic(encryptedMnemonic, userId) {
|
||||
try {
|
||||
const key = process.env.ENCRYPTION_KEY || 'default-key-12345';
|
||||
const bytes = CryptoJS.AES.decrypt(encryptedMnemonic, key + userId.toString());
|
||||
return bytes.toString(CryptoJS.enc.Utf8);
|
||||
} catch (error) {
|
||||
console.error('Error decrypting mnemonic:', error);
|
||||
throw new Error('Failed to decrypt mnemonic');
|
||||
}
|
||||
}
|
||||
|
||||
static async generateWallets(mnemonic) {
|
||||
try {
|
||||
const seed = await bip39.mnemonicToSeed(mnemonic);
|
||||
|
||||
Reference in New Issue
Block a user