deriveAddress function
Create a hash digest from the data with an hash algorithm identification prepending the digest.
seed
: Keypair derivation seedindex
: Number to identify the order of keys to generatecurve
: 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,
]),
);
}