#NEWLINE# @ defer . inlineCallbacks #NEWLINE# def _check_signature( self , event , auth_events ) : #NEWLINE# #INDENT# "\n        Checks that the signature in the event is consistent with its invite.\n        :param event (Event): The m.room.member event to check\n        :param auth_events (dict<(event type, state_key), event>)\n\n        :raises\n            AuthError if signature didn't match any keys, or key has been\n                revoked,\n            SynapseError if a transient error meant a key couldn't be checked\n                for revocation.\n        " #NEWLINE# signed = event . content [ 'third_party_invite' ] [ 'signed' ] #NEWLINE# token = signed [ 'token' ] #NEWLINE# invite_event = auth_events . get ( ( EventTypes . ThirdPartyInvite , token ) ) #NEWLINE# if ( not invite_event ) : #NEWLINE# #INDENT# raise AuthError ( 403 , 'Could not find invite' ) #NEWLINE# #UNINDENT# last_exception = None #NEWLINE# for public_key_object in self . hs . get_auth ( ) . get_public_keys ( invite_event ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# for ( server , signature_block ) in signed [ 'signatures' ] . items ( ) : #NEWLINE# #INDENT# for ( key_name , encoded_signature ) in signature_block . items ( ) : #NEWLINE# #INDENT# if ( not key_name . startswith ( 'ed25519:' ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# public_key = public_key_object [ 'public_key' ] #NEWLINE# verify_key = decode_verify_key_bytes ( key_name , decode_base64 ( public_key ) ) #NEWLINE# verify_signed_json ( signed , server , verify_key ) #NEWLINE# if ( 'key_validity_url' in public_key_object ) : #NEWLINE# #INDENT# ( yield self . _check_key_revocation ( public_key , public_key_object [ 'key_validity_url' ] ) ) #NEWLINE# #UNINDENT# return #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# last_exception = e #NEWLINE# #UNINDENT# #UNINDENT# raise last_exception