Skip to content

Commit

Permalink
fix: constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
apskhem committed Sep 19, 2024
1 parent bc41bec commit 543d6c4
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions catalyst_voices/lib/common/bip39/seed_phrase.dart
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
import 'dart:convert';
import 'package:bip39/bip39.dart' as bip39;

/// Represents a seed phrase consisting of a mnemonic and its associated seed.
/// This class provides methods for generating a new seed phrase and creating
/// one from an existing mnemonic.
///
/// The seed phrase is used for cryptographic purposes, such as generating
/// cryptocurrency wallets or secure key management.
class SeedPhrase {
final String mnemonic;
final String seed;

/// Constructor to generate a new seed phrase.
SeedPhrase()
: mnemonic = bip39.generateMnemonic(),
seed = bip39.mnemonicToSeedHex(bip39.generateMnemonic());
/// Generates a new seed phrase with a random mnemonic
/// and its corresponding seed.
SeedPhrase() : this.fromMnemonic(bip39.generateMnemonic());

/// Constructor to create a SeedPhrase from an existing mnemonic.
/// Creates a SeedPhrase from an existing [mnemonic].
SeedPhrase.fromMnemonic(this.mnemonic)
: seed = bip39.mnemonicToSeedHex(mnemonic);

/// Gets the seed hex.
/// Returns the seed hex string associated with the mnemonic.
String getSeed() {
return seed;
}

/// Gets the mnemonic.
/// Returns the mnemonic phrase.
String getMnemonic() {
return mnemonic;
}
Expand Down

0 comments on commit 543d6c4

Please sign in to comment.