verify static method

Future<Package> verify(
  1. Token token, {
  2. required PublicKey publicKey,
})

Implementation

static Future<Package> verify(
  Token token, {
  required PublicKey publicKey,
}) async {
  final payload = token.payloadPublic;
  if (payload == null) {
    throw UnsupportedError('Invalid payload');
  }
  final isValid = await Ed25519().verify(
    token.standardPreAuthenticationEncoding,
    signature: Signature(
      payload.signature!,
      publicKey: publicKey,
    ),
  );
  if (!isValid) {
    throw Exception('Invalid signature');
  }
  return Package(
    content: payload.message,
    footer: token.footer,
  );
}