Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for 12 seed phrase #40

Open
Imdavyking opened this issue Feb 28, 2023 · 1 comment
Open

add support for 12 seed phrase #40

Imdavyking opened this issue Feb 28, 2023 · 1 comment

Comments

@Imdavyking
Copy link

Please can you add support for 12 seed phrase, i have tried it but to no avail, https://github.com/abmera/bip39toalgo

@Imdavyking
Copy link
Author

Imdavyking commented Feb 28, 2023

in flutter for 12 seed phrase

import 'dart:typed_data';

import 'package:bip39/bip39.dart' as bip39;
import 'package:bip32/bip32.dart' as bip32;

class SeedPhraseRoot {
  Uint8List seed;
  bip32.BIP32 root;
  SeedPhraseRoot(Uint8List _seed, bip32.BIP32 _root) {
    seed = _seed;
    root = _root;
  }
}

SeedPhraseRoot seedFromMnemonic(seedPhrase) {
  Uint8List seed = bip39.mnemonicToSeed(seedPhrase);
  bip32.BIP32 root = bip32.BIP32.fromSeed(seed);

  return SeedPhraseRoot(seed, root);
}

Future calculateAlgorandKey(Map config) async {
  SeedPhraseRoot seedRoot_ = seedFromMnemonic(seedPhrase);
  KeyData masterKey =
      await ED25519_HD_KEY.derivePath("m/44'/283'/0'/0'/0'", seedRoot_.seed);
  final account =
      await algorandClient.loadAccountFromPrivateKey(HEX.encode(masterKey.key));
  if (config['getAlgorandKeys'] != null && config['getAlgorandKeys'] == true) {
    return account;
  }

  return {
    'address': account.publicAddress,
  };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant