deriveAddress function

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

Create a hash digest from the data with an hash algorithm identification prepending the digest.

  • seed : Keypair derivation seed
  • index : Number to identify the order of keys to generate
  • curve : Elliptic curve to use ("ed25519", "P256", "secp256k1")
  • hashAlgo : Hash algorithm ("sha256", "sha512", "sha3-256", "sha3-512", "blake2b")

Implementation

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

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