validateSignedCacao method

  1. @override
Future<bool> validateSignedCacao({
  1. required Cacao cacao,
  2. required String projectId,
})
override

Implementation

@override
Future<bool> validateSignedCacao({
  required Cacao cacao,
  required String projectId,
}) async {
  final CacaoSignature signature = cacao.s;
  final CacaoPayload payload = cacao.p;

  final reconstructed = formatAuthMessage(
    iss: payload.iss,
    cacaoPayload: CacaoRequestPayload.fromCacaoPayload(payload),
  );

  final walletAddress = AddressUtils.getDidAddress(payload.iss);
  final chainId = AddressUtils.getDidChainId(payload.iss);

  final isValid = await AuthSignature.verifySignature(
    walletAddress.toEIP55(),
    reconstructed,
    signature,
    chainId,
    projectId,
  );

  return isValid;
}