deriveArchethicKeypair function
KeyPair
deriveArchethicKeypair(
- dynamic seed,
- String derivationPath,
- int index, {
- String curve = 'ed25519',
})
Implementation
KeyPair deriveArchethicKeypair(dynamic seed, String derivationPath, int index,
{String curve = 'ed25519',}) {
// Hash the derivation path
final sha256 = Digest('SHA-256');
final hashedPath = sha256.process(Uint8List.fromList(
replaceDerivationPathIndex(derivationPath, index).codeUnits,),);
final hmac = crypto_lib.Hmac(crypto_lib.sha512, seed);
final digest = hmac.convert(hashedPath);
final extendedSeed = Uint8List.fromList(digest.bytes.sublist(0, 32));
return crypto.generateDeterministicKeyPair(
extendedSeed, curve, keychainOriginId,);
}