prepareRenew method
Prepare a private key renewal, so it can be stored on SSKS without risk of loss during the actual renew
privateKeys
- Optional. Pre-generated private keys, returned by a call to SealdSdk.generatePrivateKeysAsync.
Returns a Uint8List containing a prepared renewal.
Implementation
Uint8List prepareRenew({SealdGeneratedPrivateKeys? privateKeys}) {
if (_closed) {
throw SealdException(
code: "INSTANCE_CLOSED",
id: "FLUTTER_INSTANCE_CLOSED",
description: "Instance already closed.");
}
final Pointer<Utf8> nativeEncryptionKey =
privateKeys?.encryptionKey.toNativeUtf8() ?? nullptr;
final Pointer<Utf8> nativeSigningKey =
privateKeys?.signingKey.toNativeUtf8() ?? nullptr;
final Pointer<Pointer<Uint8>> result = calloc<Pointer<Uint8>>();
final Pointer<Int> resultLen = calloc<Int>();
final Pointer<Pointer<NativeSealdError>> err =
calloc<Pointer<NativeSealdError>>();
final int resultCode = _bindings.SealdSdk_PrepareRenew(_ptr.pointer(),
nativeEncryptionKey, nativeSigningKey, result, resultLen, err);
calloc.free(nativeEncryptionKey);
calloc.free(nativeSigningKey);
if (resultCode != 0) {
calloc.free(result);
calloc.free(resultLen);
throw SealdException._fromCPtr(err);
} else {
final Uint8List cPreparedRenew =
result.value.asTypedList(resultLen.value);
// Copying the data in a Dart-created Uint8List, to avoid having to free memory later
final Uint8List res = Uint8List.fromList(cPreparedRenew);
calloc.free(result.value);
calloc.free(result);
calloc.free(resultLen);
calloc.free(err);
return res;
}
}