checkSigchainHash method

SealdCheckSigchainResponse checkSigchainHash(
  1. String userId,
  2. String expectedHash, {
  3. int position = -1,
})

Verify if a given hash is included in the recipient's sigchain. Use the position option to check the hash of a specific sigchain transaction.

userId - The Seald ID of the concerned user. expectedHash - The expected sigchain hash. position - Position of the sigchain transaction against which to check the hash. -1 to check if the hash exist in the sigchain. Default to -1. Returns a SealdCheckSigchainResponse instance.

Implementation

SealdCheckSigchainResponse checkSigchainHash(
    String userId, String expectedHash,
    {int position = -1}) {
  if (_closed) {
    throw SealdException(
        code: "INSTANCE_CLOSED",
        id: "FLUTTER_INSTANCE_CLOSED",
        description: "Instance already closed.");
  }
  final Pointer<Utf8> nativeUserId = userId.toNativeUtf8();
  final Pointer<Utf8> nativeExpectedHash = expectedHash.toNativeUtf8();
  final Pointer<Pointer<NativeSealdCheckSigchainResponse>> result =
      calloc<Pointer<NativeSealdCheckSigchainResponse>>();
  final Pointer<Pointer<NativeSealdError>> err =
      calloc<Pointer<NativeSealdError>>();

  final int resultCode = _bindings.SealdSdk_CheckSigchainHash(_ptr.pointer(),
      nativeUserId, nativeExpectedHash, position, result, err);

  calloc.free(nativeUserId);
  calloc.free(nativeExpectedHash);

  if (resultCode != 0) {
    calloc.free(result);
    throw SealdException._fromCPtr(err);
  } else {
    final SealdCheckSigchainResponse sigchainInfo =
        SealdCheckSigchainResponse._fromC(result.value);
    calloc.free(result);
    calloc.free(err);
    return sigchainInfo;
  }
}