deriveAddress function

String deriveAddress(
  1. String seed,
  2. int index, {
  3. String curve = 'ed25519',
  4. String hashAlgo = 'sha256',
})

Create a hash digest from the data with an hash algorithm identification prepending the digest @param {String} seed Keypair derivation seed @param {int} index Number to identify the order of keys to generate @param {String} curve Elliptic curve to use ("ed25519", "P256", "secp256k1") @param {String} hashAlgo Hash algorithm ("sha256", "sha512", "sha3-256", "sha3-512", "blake2b")

Implementation

String deriveAddress(String seed, int index,
    {String curve = 'ed25519', String hashAlgo = 'sha256'}) {
  final KeyPair keypair = deriveKeyPair(seed, index, curve: curve);

  final int curveID = curveToID(curve);
  final Uint8List hashedPublicKey = hash(keypair.publicKey, algo: hashAlgo);
  return uint8ListToHex(concatUint8List(<Uint8List>[
    Uint8List.fromList(<int>[curveID]),
    hashedPublicKey
  ]));
}