'Checks that the signature in the event is consistent with its invite.
Args:
event (Event): The m.room.member event to check
context (EventContext):
Raises:
AuthError: if signature didn\'t match any keys, or key has been
revoked,
SynapseError: if a transient error meant a key couldn\'t be checked
for revocation.'

@defer.inlineCallbacks
def _check_signature(self, event, context):

    signed = event.content['third_party_invite']['signed']
    token = signed['token']
    invite_event_id = context.prev_state_ids.get((EventTypes.ThirdPartyInvite, token))
    invite_event = None
    if invite_event_id:
        invite_event = (yield self.store.get_event(invite_event_id, allow_none=True))
    if (not invite_event):
        raise AuthError(403, 'Could    not    find    invite')
    last_exception = None
    for public_key_object in self.hs.get_auth().get_public_keys(invite_event):
        try:
            for (server, signature_block) in signed['signatures'].items():
                for (key_name, encoded_signature) in signature_block.items():
                    if (not key_name.startswith('ed25519:')):
                        continue
                    public_key = public_key_object['public_key']
                    verify_key = decode_verify_key_bytes(key_name, decode_base64(public_key))
                    verify_signed_json(signed, server, verify_key)
                    if ('key_validity_url' in public_key_object):
                        (yield self._check_key_revocation(public_key, public_key_object['key_validity_url']))
                    return
        except Exception as e:
            last_exception = e
    raise last_exception
