fromPhrase static method

ICPAccount fromPhrase(
  1. String phrase, {
  2. String passphase = "",
  3. int? index,
  4. List<int>? icPath = IC_BASE_PATH,
  5. CurveType curveType = CurveType.ed25519,
})

Implementation

static ICPAccount fromPhrase(
  String phrase, {
  String passphase = "",
  int? index,
  List<int>? icPath = IC_BASE_PATH,
  CurveType curveType = CurveType.ed25519,
}) {
  ECKeys? keys = curveType == CurveType.ed25519
      ? null
      : getECKeys(phrase,
          passphase: passphase,
          index: index != null
              ? index != HARDENED
                  ? index
                  : 0
              : 0);

  var path = List<int>.from(icPath ?? IC_BASE_PATH);

  Ed25519KeyIdentity? identity = curveType == CurveType.secp256k1
      ? null
      : fromMnemonicWithoutValidation(
          phrase,
          path,
          offset: index ?? HARDENED,
        );
  Secp256k1KeyIdentity? ecIdentity = curveType == CurveType.ed25519
      ? null
      : Secp256k1KeyIdentity.fromSecretKey(keys!.ecPrivateKey!);
  return ICPAccount(curveType: curveType)
    .._ecKeys = keys
    .._identity = identity
    .._ecIdentity = ecIdentity
    .._phrase = phrase;
}