verify method

Future<bool> verify()

Verifies that the event body was signed by the device key.

Implementation

Future<bool> verify() async {
  try {
    // Verify that the signature of the event is valid.
    final isValid = await _signing.verify(
      message: unsignedMessage,
      signature: signature,
      publicKey: deviceKey,
    );
    if (!isValid) return false;

    // Additionally verify hash integrity.
    final rehashed = await _signing.hash('$unsignedMessage|$signature');

    return hash == rehashed;
  } catch (e) {
    return false;
  }
}