deriveNode function
Implementation
Map<String, Object?> deriveNode(
{required Map<String, Object?> source,
String curve = 'secp256k1',
String path = 'm'}) {
final seed = _sourceSeed(source);
if (curve == 'ed25519') {
final node = Bip32Slip10Ed25519.fromSeed(seed)
.derivePath(_path(path, ed25519: true));
return {
'schemaVersion': 1,
'curve': curve,
'path': path,
'publicKeyHex':
BytesUtils.toHexString(node.publicKey.compressed.sublist(1)),
'chainCodeHex': BytesUtils.toHexString(node.chainCode.toBytes()),
'depth': node.depth.toInt(),
'childNumber': node.index.toInt()
};
}
if (curve != 'secp256k1') {
throw WalletHDDerivationException('unsupported curve: $curve');
}
final node = Bip32Slip10Secp256k1.fromSeed(seed).derivePath(_path(path));
return {
'schemaVersion': 1,
'curve': curve,
'path': path,
'publicKeyHex': BytesUtils.toHexString(node.publicKey.compressed),
'chainCodeHex': BytesUtils.toHexString(node.chainCode.toBytes()),
'depth': node.depth.toInt(),
'childNumber': node.index.toInt()
};
}