# 2.5 Get mnemonic from secure storage and derive the wallet

All modern smartphones have a Secure Enclave Chip, that fits perfectly to keep our precious seed phrase way from bad actors.

Ok but if we are the phone owner and we actually need it how can we do it?

# Use cases

Retrieve safely your mnemonic in your Android and iOS device and then derive the pub address from wallet.

# Tools

The Sacco library, our own open source tool to sign and send transactions to any Cosmos SDK based blockchain, including Commercio.network.

The flutter_secure_storage, a Flutter plugin to store data in secure storage.

# Functions and APIs

  • Wallet derive.

# Background

From Wikipedia:

Mnemonics make use of elaborative encoding, retrieval cues, and imagery as specific tools to encode any given information in a way that allows for efficient storage and retrieval. Mnemonics aid original information in becoming associated with something more accessible or meaningful—which, in turn, provides better retention of the information.

# Step by step sequence

  1. Create new storage;
  2. Save your mnemonic in the secure storage;
  3. Read the mnemonic from the secure storage;
  4. Execute Wallet the derive function to generate the wallet;
  5. Finally, get the address from the wallet.

# Dart

import 'package:flutter_secure_storage/flutter_secure_storage.dart';

final storage = new FlutterSecureStorage();

await storage.write(
  key: 'mnemonic',
  value: 'final random flame cinnamon grunt hazard easily mutual resist pond solution define knife female tongue crime atom jaguar alert library best forum lesson rigid',
);

final storedMnemonic = await storage.read(key: 'mnemonic');
final mnemonic = storedMnemonic.split(' ');

final networkInfo = NetworkInfo(bech32Hrp: 'did:com:', lcdUrl: 'http://localhost:1317');

final wallet = Wallet.derive(mnemonic, networkInfo);

final address = wallet.bech32Address;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17