validate keyData length (32)

This commit is contained in:
sneurlax
2023-11-09 16:53:18 -06:00
parent 7118a050d3
commit 59ab5fa68f

View File

@@ -20,9 +20,13 @@ class FlutterLibsparkmobile {
/// Derive an address from the keyData (mnemonic).
Future<String> getAddress(
List<int> keyData, int index, int diversifier) async {
final keyDataHex = keyData.toHexString();
// Validate that the keyData is 32 bytes.
if (keyData.length != 32) {
throw 'Key data must be 32 bytes.';
}
// Allocate memory for the hex string on the native heap.
final keyDataHex = keyData.toHexString();
final keyDataPointer = keyDataHex.toNativeUtf8().cast<Char>();
// Call the native method with the pointer.