askarKeySignMessage function
Implementation
AskarResult<Uint8List> askarKeySignMessage(
LocalKeyHandle handle,
Uint8List message,
SignatureAlgorithm sigType,
) {
Pointer<NativeSecretBuffer> secretBufferPointer = calloc<NativeSecretBuffer>();
Pointer<Utf8> sigTypePointer = nullptr;
Pointer<NativeByteBuffer> byteBufferPointer = nullptr;
try {
sigTypePointer = sigType.value.toNativeUtf8();
byteBufferPointer = bytesListToByteBuffer(message);
NativeByteBuffer byteBuffer = byteBufferPointer.ref;
final funcResult = nativeAskarKeySignMessage(
handle.toInt(),
byteBuffer,
sigTypePointer,
secretBufferPointer,
);
final errorCode = ErrorCode.fromInt(funcResult);
final value =
(errorCode == ErrorCode.success)
? secretBufferToBytesList(secretBufferPointer.ref)
: Uint8List(0);
return AskarResult<Uint8List>(errorCode, value);
} finally {
freeSecretBufferPointer(secretBufferPointer);
freePointer(sigTypePointer);
freeByteBufferPointer(byteBufferPointer);
}
}